Traverse all Vertecies without removing duplicates (orientdb-community-2.0)

147 views
Skip to first unread message

Emin Agassi

unread,
Jun 1, 2015, 8:58:04 AM6/1/15
to orient-...@googlegroups.com
Hello All
I am traversing a Graph that has some common Vertices. When I execute traverse, I only see one instance of the common Vertix versus several.
For example,

A -> B
C -> B

After traverse, I only see the following result:

A
C
B (common and pointed to by A and C)

I would like to see the duplicate Vertix in the result as follows:

A
B (Common to A and C)
C
B (Common to A and C)

Is there a method to achieve this or Traverse always returns Distinct Vertices?

Thank you
Emin


Luigi Dell'Aquila

unread,
Jun 1, 2015, 11:39:00 AM6/1/15
to orient-...@googlegroups.com
Hi Emil,

Traverse was implemented this way to avoid infinite loops, but now we know it's a limitation and we are thinking about a finer strategy, where the user can define (per single query) how traversed nodes have to be considered:
- skip traversed nodes globally
- skip traversed nodes in current path
- never skip
- other...

This feature is not tracked yet in the issue tracker, could you please open an issue about this?

Thanks

Luigi


--

---
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 orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Emin Agassi

unread,
Jun 1, 2015, 11:56:05 AM6/1/15
to orient-...@googlegroups.com
Ok, thank you.
What alternatives do I have now since this feature is not supported by SQL?
Can I use Java Blueprints api to manually traverse?
The Java Blueprints API seems to work fine.

Luigi Dell'Aquila

unread,
Jun 1, 2015, 12:01:13 PM6/1/15
to orient-...@googlegroups.com
yes, Java Blueprints lets you manage this manually.
As an alternative, you can define a Javascript function, based on your use case, and use it in your queries

Luigi


Emin Agassi

unread,
Jun 1, 2015, 12:21:52 PM6/1/15
to orient-...@googlegroups.com
Is there an example of the JS script function embedded in the SQL that you can point me too?
Thank you!


On Monday, June 1, 2015 at 8:58:04 AM UTC-4, Emin Agassi wrote:

SavioL

unread,
Jun 3, 2015, 10:18:51 AM6/3/15
to orient-...@googlegroups.com
Hi Emin,

this is JavaScript function that you were looking for:

var gdb = orient.getGraphNoTx();
var list = gdb.command( "sql", "select expand(in('link_to_school')) from Scuola");

var start;
var scuola;
var lista;
var end;
var loadlist = 0;

var nomepersona
var nomescuola

for(i=0; i<list.length; i++) {
 
  start = list[i].getId().toString()+"";
  scuola =  gdb.command( "sql",  "select in from link_to_school where out = '"+start+"'");
  end = scuola[0].getProperty("in").getId().toString()+"";   
 
  if(loadlist == 0) {
   
    loadlist = 1;
    nomepersona =  gdb.command( "sql",  "select name from persona where @rid='"+start+"' ");
    nomescuola =  gdb.command( "sql",  "select nameschool from scuola where @rid='"+end+"' ");
   
    lista = nomepersona[0].getProperty("name") +" --> "+ nomescuola[0].getProperty("nameschool") +"; ";
       
  } else {
     nomepersona =  gdb.command( "sql",  "select name from persona where @rid='"+start+"' ");
     nomescuola =  gdb.command( "sql",  "select nameschool from scuola where @rid='"+end+"' ");
   
    lista = lista + nomepersona[0].getProperty("name") +" --> "+ nomescuola[0].getProperty("nameschool") +"; ";
  }
 
}

return lista;


The result returned is


Regards,

Luigi S.

Emin Agassi

unread,
Oct 28, 2015, 9:44:23 AM10/28/15
to OrientDB
Luigi,

Thank you for this help. I will try this.
Emin
Reply all
Reply to author
Forward
0 new messages