Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null DiGraph #156

Open
oyamad opened this issue Jun 6, 2015 · 0 comments
Open

Null DiGraph #156

oyamad opened this issue Jun 6, 2015 · 0 comments

Comments

@oyamad
Copy link
Member

oyamad commented Jun 6, 2015

This is a tiny point, but just for record:

  • Should graph_tools.DiGraph allow a null graph (a graph with no node)? (It is allowed in the current implementation.)
  • If so, is a null digraph strongly connected? (It is not in the current implementation.)
>>> adj_matrix = np.array([]).reshape(0, 0)
>>> adj_matrix
array([], shape=(0, 0), dtype=float64)
>>> null_digraph = qe.DiGraph(adj_matrix)
>>> null_digraph
Directed Graph:
  - n(number of nodes): 0
>>> null_digraph.is_strongly_connected
False
>>> null_digraph.num_strongly_connected_components
0
>>> null_digraph.strongly_connected_components
[]
>>> null_digraph.num_sink_strongly_connected_components
0
>>> null_digraph.sink_strongly_connected_components
[]

In passing, in Networkx whether or not a null digraph is strongly connected is undefined.

>>> import networkx as nx
>>> G = nx.DiGraph()
>>> G.number_of_nodes()
0
>>> nx.is_strongly_connected(G)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 2, in is_strongly_connected
  File "/usr/local/lib/python2.7/site-packages/networkx/utils/decorators.py", line 68, in _not_implemented_for
    return f(*args,**kwargs)
  File "/usr/local/lib/python2.7/site-packages/networkx/algorithms/components/strongly_connected.py", line 287, in is_strongly_connected
    """Connectivity is undefined for the null graph.""")
networkx.exception.NetworkXPointlessConcept: Connectivity is undefined for the null graph.
>>> nx.number_strongly_connected_components(G)
0
>>> list(nx.strongly_connected_components(G))
[]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants