So, im creating nodes (2 input and 2 output). And I want to connect those nodes with links. for this I have the class Node and the class Link.
class Node:
all_link_incoming = []
all_link_outgoing = []
class Link:
node_incoming = 0.0
node_outgoing = 0.0
I want to connect each Input node with both Output nodes, thus creating a link from input node 1 to output nodes 1 and 2. (see following image) nodes
To create the links that connect these nodes, I use the following piece of code:
for node_input in all_node_input:
for node_output in all_node_output:
link = Link(node_input, node_output)
node_input.all_link_outgoing.append(link)
node_output.all_link_incoming.append(link)
However, after both for loops have run once (So input node 1 should be connected to output node 1, nothing else). Output node 2 also contains the (same) created link to input node 1.
So after running this piece of code, each output node should contain 2 links, but they both contain the same 4 links.
Does anyone see what I'm doing wrong? Thanks a lot!
(Btw, I added some debug lines to check this, these lines and output looks like:)
print(all_node_output[0].all_link_incoming)
print(all_node_output[1].all_link_incoming)
[<__main__.Link object at 0x104704d30>, <__main__.Link object at 0x104704d68>, <__main__.Link object at 0x104704da0>, <__main__.Link object at 0x104704dd8>]
[<__main__.Link object at 0x104704d30>, <__main__.Link object at 0x104704d68>, <__main__.Link object at 0x104704da0>, <__main__.Link object at 0x104704dd8>]