Hi Josh,
I tried to do this little Java function,
let me know if the function is like that you expect.
private Vertex myFunction(OrientGraph g){
String name="Doc 4";
int counter=0;
int steps=2;
Vertex vP=null;
Iterable<Vertex> result=g.command(new OSQLSynchQuery<Vertex>("select from
Document where name = '"+name+"'")).execute();
if(result.iterator().hasNext()){
Vertex p=result.iterator().next();
vP=p;
}
while(counter<steps){
Iterable<Vertex> listMetadata=g.command(new OSQLSynchQuery<Vertex>("select
expand(out('metadata_of')) from Document where @rid = " +
vP.getId().toString() + ")")).execute();
Vertex vMetadata=null;
int min=0;
for(Vertex v:listMetadata){
String stringNumber=v.getEdges(Direction.IN, "metadata_of").toString();
stringNumber=stringNumber.replace("[", "").replace("]", "");
int numero=Integer.parseInt(stringNumber);
if(vMetadata==null || numero<min ){
vMetadata=v;
min=numero;
}
}
Iterable<Edge> edges=vMetadata.getEdges(Direction.IN, "metadata_of");
float peso=0.0f;
Vertex v0=null;
for(Edge e:edges){
float pesoArco=e.getProperty("weight");
Vertex vOut=e.getVertex(Direction.OUT);
if((v0==null || pesoArco>peso) && vP.getId()!=vOut.getId()){
v0=vOut;
peso=pesoArco;
}
}
if(v0!=null){
vP=v0;
}
else{
break;
}
counter++;
}
return vP;
}
Alessandro
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.