-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph_building.py
65 lines (65 loc) · 1.96 KB
/
graph_building.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
65
# coding: utf-8
import networkx as nx
G = nx.complete_graph(5)
nx.drawing.nx_pydot.write_dot(G, '5-connect.dot')
Bool_one = nx.MultiDigraph()
Bool_one = nx.MultiDiGraph()
Bool_one.add_node('True')
Bool_one.add_node('False')
Bool_one.node[0]
Bool_one.nodes()
Bool_one.nodes(data=True)
Bool_one.nodes['True']
Bool_one.node['True']
Bool_one.node['True']['label'] = 'True'
nx.drawing.nx_pydot.write_dot(G, 'Bool.dot')
nx.drawing.nx_pydot.write_dot(Bool_one, 'Bool.dot')
Bool_one.node['True']['label'] = 'True!'
nx.drawing.nx_pydot.write_dot(Bool_one, 'Bool.dot')
Bool_one.node['True']['label'] = 'True'
Bool_one.node['True']['shape'] = 'box'
nx.drawing.nx_pydot.write_dot(Bool_one, 'Bool.dot')
Bool_one.node['True']['shape'] = 'box'
Bool_one.node['False']['shape'] = 'box'
del Bool_one
B = nx.MultiDiGraph()
B[False] = {}
B.add_node(True)
B.add_node(False)
nx.drawing.nx_pydot.write_dot(B, 'Bool.dot')
B.nodes[True]['shape'] = 'box'
B.node[True]['shape'] = 'box'
B.node[False]['shape'] = 'box'
nx.drawing.nx_pydot.write_dot(B, 'Bool.dot')
B.add_edge(True, True, label='ID(True)')
B.add_edge(False, False, label='ID(False)')
nx.drawing.nx_pydot.write_dot(B, 'Bool.dot')
B.add_edge(True, False, label='!(True)')
B.add_edge(False, True, label='!(False)')
nx.drawing.nx_pydot.write_dot(B, 'Bool.dot')
B.node[True]['color'] = 'red'
nx.drawing.nx_pydot.write_dot(B, 'Bool.dot')
B.node[True]['color'] = 'blue'
B.node[False]['color'] = 'red'
nx.drawing.nx_pydot.write_dot(B, 'Bool.dot')
bt = nx.MultiDiGraph()
bt.add_node('x0')
bt.add_node('ID')
bt.add_node('NEG')
bt.add_link('x0','ID')
bt.add_edge('x0','ID')
bt.add_edge('x0','NEG')
bt.add_edge('NEG','NEG(T)')
bt.add_edge('NEG','NEG(F)')
bt.add_edge('ID','ID(T)')
bt.add_edge('ID','ID(F)')
nx.drawing.nx_pydot.write_dot(bt, 'bintree.dot')
nx.drawing.nx_agraph.to_agraph.__doc__
print nx.drawing.nx_agraph.to_agraph.__doc__
print nx.drawing.nx_agraph.write_dot.__doc__
print nx.drawing.nx_agraph.__doc__
bt
bt.nodes
bt.nodes()
get_ipython().magic(u'save')
help %save