ELIFE-ASU / Neet

Simulating and analyzing dynamical network models
https://neet.readthedocs.io/en/stable
Other
4 stars 10 forks source link

Network.network_graph discards disconnected nodes #194

Closed dglmoore closed 4 years ago

dglmoore commented 4 years ago

Description

When a Neet network has a single node that is disconnected from the rest of the network, the Network.network_graph method fails to include it in the networkx.DiGraph. This is because we are using the networkx.DiGraph(edges) initializer which only includes if they are an endpoint of one of the edges provided.

Neet Version: 1.0.0 Operating System: ChromeOS 79

To Reproduce

Describe the steps to reproduce the bug, and include a script if possible.

  1. Create a LogicNetwork with a three nodes, two connected and one free
  2. Convert to a networkx.DiGraph with Network.network_graph
  3. Confirm that there are 3 nodes in the LogicNetwork and only 2 in the the networkx.DiGraph
>>> net = LogicNetwork([((), set()), ((2,), {'1'}), ((1,), {'0'})])
>>> net.size
3
>>> len(net.network_graph())
2

Expected Behavior

The number of nodes in the resulting DiGraph should be the same as the number of nodes in the network.

Actual Behavior

Lone nodes are discarded.