annotate importFromOpenMind/importer/compare_models.py @ 48:6625019a0c96

old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
author casties
date Tue, 07 Feb 2017 21:06:13 +0100
parents 378dcb66a27f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
1 import networkx as nx
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
2 import sys
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
3 import csv
48
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
4 from sqlalchemy.sql.expression import false
47
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
5
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
6 ## configure behaviour
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
7
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
8 # metworkx graph files
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
9 input1_fn = 'ismi_graph1.gpickle'
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
10 input2_fn = 'ismi_graph2.gpickle'
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
11
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
12 # name of type attribute
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
13 node_type_attribute = '_type'
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
14 rel_type_attribute = '_type'
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
15
48
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
16 # also compare attributes
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
17 check_attributes = True
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
18 check_attribute_content = False
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
19
47
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
20 # active log levels for logging
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
21 logLevels = {'DEBUG', 'INFO', 'WARNING', 'ERROR', 'SYSMSG'}
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
22 #logLevels = {'INFO', 'WARNING', 'ERROR', 'SYSMSG'}
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
23 #logLevels = {'INFO', 'ERROR', 'SYSMSG'}
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
24
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
25 def log(level, message):
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
26 if level in logLevels:
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
27 print("%s: %s"%(level, message))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
28
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
29
48
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
30 def compare_attributes(attrs1, attrs2):
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
31 """compare two sets of attributes"""
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
32 for a in attrs1.keys():
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
33 if a.startswith('_n_'):
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
34 continue
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
35
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
36 if a not in attrs2:
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
37 log('DEBUG', "attribute %s missing in attrs2"%a)
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
38 return False
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
39
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
40 elif check_attribute_content:
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
41 val1 = attrs1[a]
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
42 val2 = attrs2[a]
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
43 if isinstance(val1, str):
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
44 val1 = val1.replace('\r', '')
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
45 val2 = val2.replace('\r', '')
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
46
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
47 if val1 != val2:
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
48 log('DEBUG', "attribute %s different in attrs2: \n%s\n vs \n%s\n"%(a, repr(val1), repr(val2)))
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
49 return False
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
50
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
51 for a in attrs2.keys():
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
52 if a.startswith('_n_'):
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
53 continue
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
54
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
55 if a not in attrs1:
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
56 log('DEBUG', "attribute %s missing in attrs1"%a)
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
57 return False
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
58
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
59 return True
47
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
60
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
61 def compare_nodes(nx_graph1, nx_graph2):
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
62 """compare nodes of two graphs"""
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
63
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
64 log('INFO', "Compare graph nodes: %s vs %s"%(repr(nx_graph1), repr(nx_graph2)))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
65 cnt = 0
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
66 missing_nodes1 = []
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
67 missing_nodes2 = []
48
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
68 attribute_differences = []
47
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
69 # iterate all nodes in graph 1
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
70 for n in nx.nodes_iter(nx_graph1):
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
71 if not nx_graph2.has_node(n):
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
72 missing_nodes2.append(n)
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
73
48
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
74 else:
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
75 attrs1 = nx_graph1.node[n]
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
76 attrs2 = nx_graph2.node[n]
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
77 if check_attributes and not compare_attributes(attrs1, attrs2):
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
78 attribute_differences.append(n)
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
79
47
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
80 if len(missing_nodes2) > 0:
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
81 log('WARNING', "%s nodes missing in graph 2"%len(missing_nodes2))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
82 log('DEBUG', "nodes: %s"%missing_nodes2)
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
83 #log('DEBUG', "nodes: %s"%([nx_graph1.node[n] for n in missing_nodes2]))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
84
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
85 # iterate all nodes in graph 2
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
86 for n in nx.nodes_iter(nx_graph2):
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
87 #attrs = nx_graph.node[n]
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
88
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
89 if not nx_graph1.has_node(n):
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
90 missing_nodes1.append(n)
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
91
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
92 if len(missing_nodes1) > 0:
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
93 log('WARNING', "%s nodes missing in graph 1"%len(missing_nodes1))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
94 log('DEBUG', "nodes: %s"%(missing_nodes1))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
95
48
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
96 if len(attribute_differences) > 0:
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
97 log('WARNING', "%s nodes with attribute differences"%len(attribute_differences))
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
98 log('DEBUG', "nodes: %s"%(attribute_differences))
6625019a0c96 old model2neo4j renamed to model2neo4j_restclient. new model2neo4j_client and model2neo4j_import. fixed ismixml2model and compare_models.
casties
parents: 47
diff changeset
99
47
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
100
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
101 def compare_relations(nx_graph1, nx_graph2):
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
102 """compare relations of two graphs"""
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
103
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
104 log('INFO', "Compare graph relations: %s vs %s"%(repr(nx_graph1), repr(nx_graph2)))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
105 cnt = 0
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
106 missing_rels1 = []
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
107 missing_rels2 = []
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
108 # iterate all edges in graph 1
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
109 for (s, t) in nx.edges_iter(nx_graph1):
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
110
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
111 if not nx_graph2.has_edge(s, t):
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
112 missing_rels2.append((s,t))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
113
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
114 if len(missing_rels2) > 0:
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
115 log('WARNING', "%s relations missing in graph 2"%len(missing_rels2))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
116 log('DEBUG', "relations: %s"%missing_rels2)
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
117 #log('DEBUG', "nodes: %s"%([nx_graph1.node[n] for n in missing_nodes2]))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
118
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
119 # iterate all nodes in graph 2
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
120 for (s, t) in nx.edges_iter(nx_graph2):
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
121 #attrs = nx_graph.node[n]
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
122
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
123 if not nx_graph1.has_edge(s, t):
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
124 missing_rels1.append((s,t))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
125
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
126 if len(missing_rels1) > 0:
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
127 log('WARNING', "%s relations missing in graph 1"%len(missing_rels1))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
128 log('DEBUG', "relations: %s"%(missing_rels1))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
129
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
130
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
131 ## main
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
132
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
133 print("Modify networkx graph")
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
134
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
135 # read commandline parameters
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
136 if len(sys.argv) > 2:
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
137 input1_fn = sys.argv[1]
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
138 input2_fn = sys.argv[2]
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
139
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
140 # read networkx graph from pickle
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
141 print("Reading graph 1 from %s"%input1_fn)
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
142 nx_graph1 = nx.read_gpickle(input1_fn)
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
143 print("Graph 1 info: %s"%nx.info(nx_graph1))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
144
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
145 print("Reading graph 2 from %s"%input2_fn)
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
146 nx_graph2 = nx.read_gpickle(input2_fn)
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
147 print("Graph 2 info: %s"%nx.info(nx_graph2))
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
148
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
149 # operate
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
150 compare_nodes(nx_graph1, nx_graph2)
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
151 compare_relations(nx_graph1, nx_graph2)
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
152
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
153
378dcb66a27f new compare_models comparing the existence of nodes and relations in two graphs.
casties
parents:
diff changeset
154 print("Done.")