jacquesfize / GMatch4py

A graph matching library for Python
MIT License
192 stars 41 forks source link

How does the node attr works? #26

Closed MikeWangWZHL closed 3 years ago

MikeWangWZHL commented 3 years ago

I compare two graphs as follows:

g1=nx.DiGraph()
g1.add_edges_from([(0,3),(1,3),(2,3)])
g1.nodes[0]['type'] = 'Attack'
g1.nodes[1]['type'] = 'Attack'
g1.nodes[2]['type'] = 'Attack'
g1.nodes[3]['type'] = 'Die'

g2=nx.DiGraph()
g2.add_edges_from([(0,3),(1,3),(2,3)])
g2.nodes[0]['type'] = 'Die'
g2.nodes[1]['type'] = 'Die'
g2.nodes[2]['type'] = 'Die'
g2.nodes[3]['type'] = 'Attack'

ged = gm.GraphEditDistance(1,1,1,1)
ged.set_attr_graph_used('type',None)
result = ged.compare([g1,g2],None)

And the comparing result is [[0,0], [0,0]] So it seems that the ged didn't consider the 'type' attribute?

elizabethdinella commented 3 years ago

I'm experiencing the same bug. Did you figure out how to compare using node attributes?

MikeWangWZHL commented 3 years ago

Hi, I actually switch to using networkx graph edit distance algorithm, maybe you can try it out?