comparison env/lib/python3.9/site-packages/networkx/generators/tests/test_cographs.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 """Unit tests for the :mod:`networkx.generators.cographs` module.
2
3 """
4
5 import networkx as nx
6
7
8 def test_random_cograph():
9 n = 3
10 G = nx.random_cograph(n)
11
12 assert len(G) == 2 ** n
13
14 # Every connected subgraph of G has diameter <= 2
15 if nx.is_connected(G):
16 assert nx.diameter(G) <= 2
17 else:
18 components = nx.connected_components(G)
19 for component in components:
20 assert nx.diameter(G.subgraph(component)) <= 2