Issue with Depth first traversal using Titan 0.5.4

83 views
Skip to first unread message

tribhuw...@perspicanetworks.com

unread,
Mar 2, 2015, 2:25:42 PM3/2/15
to aureliu...@googlegroups.com
Hi,

I am new to Titan and Gremlin.
I am doing a depth first search on the graph which is a DAG from root to leafs( loaded from the JSON file ) using the GremlinePipeline java class. I am getting the BFS results instead of DFS.

the code is as follows -->

GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>();
pipe = pipe.start(g.getVertex(v.getId())).as("x").outE("manages").inV().loop("x", whileFunction, emitFunction);


//the whileFunction is -->

  PipeFunction<LoopBundle<Vertex>, Boolean> whileFunction = new PipeFunction<LoopBundle<Vertex>, Boolean>() {

                        @Override
                        public Boolean compute(LoopBundle<Vertex> bundle) {
                            // System.out.println("looping vertex---------"
                            // + bundle.getObject().getProperty("name"));
                            bundle.getLoops();

                            Iterable<Edge> itr = bundle.getObject().getEdges(
                                    Direction.OUT, "manages");

                            if (itr.iterator().next() == null)
                                return false;
                            else
                                return true;
                        }

                    }


Is is a right way to configure a DFS pipe?
Is there any issue with Titan 0.5.4?


Regards
Negi

Daniel Kuppitz

unread,
Mar 3, 2015, 3:45:57 AM3/3/15
to aureliu...@googlegroups.com
Hi,

a loop step always turns your traversal into a BFS traversal. If you need DFS, you'll have to use some kind of a for-loop and reconstruct the GremlinPipeline in each iteration (iirc there's no easy way to clone a GremlinPipeline).

Cheers,
Daniel



--
You received this message because you are subscribed to the Google Groups "Aurelius" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraph...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aureliusgraphs/b40e434e-2932-46be-bc9b-e319a0b3a83b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

tribhuwan negi

unread,
Mar 9, 2015, 12:33:03 PM3/9/15
to aureliu...@googlegroups.com
Thanks Daniel.
I exactly did the same. Wrote a DFS using GremLinePipeLine. Why there is no API to do it?


Negi
Reply all
Reply to author
Forward
0 new messages