-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-figures.py
64 lines (58 loc) · 2.48 KB
/
make-figures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import networkx as nx, community, csv
import matplotlib.style as style, matplotlib.pyplot as plt
from networkx.drawing.nx_agraph import graphviz_layout
import dzcnapy_plotlib as dzcnapy
F = nx.DiGraph()
F.add_node("C")
F.add_edges_from([("B", "b0"), ("b0", "b1"), ("b1", "B")])
F.add_edges_from([("A", "a0"), ("a0", "a1"), ("a1", "a2"), ("a1", "a3"), ("a3", "A")])
pos = graphviz_layout(F)
nx.draw_networkx(F, pos, **dzcnapy.attrs)
dzcnapy.set_extent(pos, plt)
dzcnapy.plot("abcNwtwork")
G = nx.Graph(
(("Alpha", "Bravo"), ("Bravo", "Charlie"), ("Charlie", "Delta"),
("Charlie", "Echo"), ("Charlie", "Foxtrot"), ("Delta", "Echo"),
("Delta", "Foxtrot"), ("Echo", "Foxtrot"), ("Echo", "Golf"),
("Echo", "Hotel"), ("Foxtrot", "Golf"), ("Foxtrot", "Hotel"),
("Delta", "Hotel"), ("Golf", "Hotel"), ("Delta", "India"),
("Charlie", "India"), ("India", "Juliet"), ("Golf", "Kilo"),
("Alpha", "Kilo"), ("Bravo", "Lima")))
pos = graphviz_layout(G)
core = nx.k_core(G)
crust = nx.k_crust(G)
corona3 = nx.k_corona(G, k=3).nodes()
nx.draw_networkx(G, pos, nodelist=core, **dzcnapy.attrs)
nx.draw_networkx_edges(G, pos, core.edges(), **dzcnapy.tick_attrs)
nx.draw_networkx_edges(G, pos, crust.edges(), **dzcnapy.tick_attrs)
nx.draw_networkx_nodes(G, pos, crust, node_shape='v', **dzcnapy.attrs)
nx.draw_networkx_nodes(G, pos, corona3, node_shape='s', **dzcnapy.attrs)
dzcnapy.set_extent(pos, plt)
dzcnapy.plot("CoresAndCoronas")
# Generate a 5-clique
G = nx.complete_graph(5, nx.Graph())
nx.relabel_nodes(G, dict(enumerate(("Alpha", "Bravo", "Charlie", "Delta", "Echo"))),
copy=False)
# Attach a pigtail to it
G.add_edges_from([("Echo", "Foxtrot"), ("Foxtrot", "Golf"), ("Foxtrot", "Hotel"),
("Golf", "Hotel")])
pos = graphviz_layout(G)
nx.draw_networkx(G, pos, **dzcnapy.attrs)
nx.find_cliques(G)
for g in nx.find_cliques(G):
if len(g) >b 2:
nx.draw_networkx_edges(G, pos, nx.subgraph(G,g).edges(),
**dzcnapy.thick_attrs)
dzcnapy.set_extent(pos, plt)
dzcnapy.plot("MaximalClique")
G = nx.complete_graph(5, nx.Graph())
nx.relabel_nodes(G, dict(enumerate(("Alpha", "Bravo", "Charlie",
"Delta", "Echo"))), copy=False)
missing = ("Delta", "Echo")
G.remove_edge(*missing)
pos = graphviz_layout(G)
nx.draw_networkx(G, pos, **dzcnapy.attrs)
nx.draw_networkx_edges(G, pos, edgelist=(missing,), style='dashed',
**dzcnapy.attrs)
dzcnapy.set_extent(pos, plt)
dzcnapy.plot("CliqueCommunity")