Vertex ordering within motif vertex maps
Bug reports:
Please follow the general troubleshooting steps first:
-
Are you running the latest graph-tool
version? -
Do you observe the problem with the current git version? -
Are you using Macports or Homebrew? If yes, please submit an issue there instead: https://github.com/Homebrew/brew/issues and https://trac.macports.org/newticket -
Did you compile graph-tool
manually? -
If you answered yes above, did you use the exact same compiler to build graph-tool
,boost-python
andPython
?
I am currently working with the clustering.motifs function and ran into a issue about the ordering of vertices in the returned vertex maps. Let me illustrate by an example:
edges = [(0, 1), (0, 2), (0, 3), (1, 3), (2, 3), (3, 4), (3, 5), (4, 6), (4, 7), (5, 7), (6, 8), (6, 9), (8, 9)]
gt_graph3 = gt.Graph(edges, directed=False)
motifs, counts, locations = gt.clustering.motifs(gt_graph3, 3, return_maps = True, motif_list = None)
for g, count, locations in zip(*(motifs, counts, locations)):
print(g.get_edges())
print([l.a for l in locations])
For d = 3 one of the motifs is simply a path with edges (0, 1), (1, 2) (i.e. node “1” is the middle node of the path) The locations vertex map returns a list with entries [0, 3, 5], [0, 3, 4], [0, 1, 2] etc. that each map to a triple of vertices where this motif can be found. Now I noticed that the order of the labels of these vertices is increasing, instead of in the same order as the motif. More specifically, we have that nodes (0, 3, 5) indeed form a path with node 3 in the middle, but on the other hand nodes (0, 1, 2) also form a path but with node 0 in the middle.
Is it possible to ensure that the ordering of nodes in the vertex maps is the same as within the motif? This would mean that the vertex maps would be (0, 3, 5), (0, 3, 4), (1, 0, 2) etc. I have graphtool version 2.59
thank you!