-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdiff.py
30 lines (19 loc) · 1.17 KB
/
diff.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
from graph_algorithms import diff
import json
import networkx
BLOCKLIST = ['CRAWLER_CONFIG', 'navigator.connection.downlink', 'navigator.connection.rtt', 'clientInformation.connection.rtt', 'document.lastModified', 'document.timeline.currentTime', 'performance', 'navigation.currentEntry.id', 'navigation.currentEntry.key', 'clientInformation.connection.downlink', 'XSL_inclusionMethod.contentDocument.timeline', 'XSL_inclusionMethod.contentDocument.lastModified', 'clientInformation.connection.effectiveType', 'mozInnerScreenY', 'XSL_events.error.0.filename'] #, 'outerWidth', 'outerHeight', 'screenLeft', 'screenX', 'screenY', 'screenTop'
def convertToNetworkxGraph(g):
# g is a json graph
return networkx.node_link_graph(
g,
directed=True,
multigraph=True,
source="source",
target="target",
key="key", # key and edgelabel are redundant. We duplicate edgelabel to key because networkx does delete this attribute while importing
name="name"
)
def diffGraphs(g1, g2):
G1 = convertToNetworkxGraph(json.loads(g1))
G2 = convertToNetworkxGraph(json.loads(g2))
return diff([G1, G2], path_exclude_keywords=BLOCKLIST)