I am new to Gremlin and I am trying to implement the pagerank algorithm with edge weights from JUNG. These are the steps I have taken. I have 2.0.0.0 version of Gremlin installed. I have created a .graphml file using the iGraph package in R, which I am loading into gremlin.
import edu.uci.ics.jung.algorithms.scoring.PageRank
g1 = new TinkerGraph()
g1.loadGraphML('file path.graphml')
My g1 graph has the following edge attributes:
g1.E.map
==>{weight=1, freq=1}
==>{weight=1, freq=1}
==>{weight=2, freq=2}
==>{weight=1, freq=1}
==>{weight=1, freq=1}
==>{weight=1, freq=1}
==>{weight=1, freq=1}
==>{weight=1, freq=1}
==>{weight=2, freq=2}
gremlin> g1.V.map
==>{name=a}
==>{name=b}
==>{name=c}
==>{name=d}
==>{name=e}
==>{name=f}
==>{name=g}
==>{name=h}
==>{name=i}
==>{name=k}
j = new GraphJung(g1)
t = new EdgeWeightTransformer("weight",true, false)
pr = new PageRank<Vertex,Edge>(j, t, 0.15d)
pr.evaluate()
j.getVertices().collect{[it, pr.getVertexScore(it)]}
However, my results are
==>[v[n1], 0.046875]
==>[v[n0], 0.046875]
==>[v[n5], 0.046875]
==>[v[n4], 0.046875]
==>[v[n3], 0.046875]
==>[v[n2], 0.046875]
==>[v[n9], 0.046875]
==>[v[n8], 0.046875]
==>[v[n7], 0.046875]
==>[v[n6], 0.046875]
which are are incorrect. Please can someone help me understand what is wrong in the code. I also tried to check the effect of the transformer on the edge weights of j by the following: j.getEdges().t.
I get NULLS when I do this.
But I know there are weights associated with these edges as when I run:
j.getEdges().collect{[it, it.weight]}
I get the following results:
==>[e[3][n1-_default->n5], 1]
==>[e[2][n0-_default->n4], 1]
==>[e[1][n0-_default->n3], 2]
==>[e[0][n0-_default->n2], 1]
==>[e[7][n1-_default->n8], 1]
==>[e[6][n1-_default->n7], 1]
==>[e[5][n1-_default->n6], 1]
==>[e[4][n1-_default->n1], 1]
==>[e[8][n1-_default->n9], 2]
Finally, I am unable to create automatic keys for my vertices. I tried
g1.createAutoIndex('test', Vertex.class, ['name'] as Set)
And got the following error:
No signature of method: groovy.lang.MissingMethodException.createAutoIndex() is applicable for argument types: () values: []
Thank you