Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need more clarifications over traverse function #25

Closed
afidegnum opened this issue Oct 5, 2016 · 4 comments
Closed

Need more clarifications over traverse function #25

afidegnum opened this issue Oct 5, 2016 · 4 comments
Labels

Comments

@afidegnum
Copy link

on arango.graph.Graph,

can you please explain the following and give examples of the following functions:
init_func
sort_func
visitor_func
expander_func
filter_function

i m still having difficulties traversing the graphs, when i added contents to the child graphs, the whole traversal system changed.

@joowani
Copy link
Contributor

joowani commented Oct 6, 2016

Hi afidegnum,

For those arguments you must pass in javascript functions with pre-determined signatures that you must abide by. The functions allow you to customize the traversal behaviour. Python-arango is built right on top of ArangoDB's REST API, whose documenation will probably give you more information.

If you look at the link you will notice that the parameter names have changed slightly:

init_func --> init
sort_func --> sort
visitor_func --> visitor
expander_func --> expander
filter_func --> filter

Here are some examples from it:

init_func="result.visited = 0; result.myVertices = [ ];"

visitor_func="result.visited.vertices.push(vertex._id);"

expander_func="var connections = [ ];if (vertex.name === \"Alice\") {config.datasource.getInEdges(vertex).forEach(function (e) {connections.push({ vertex: require(\"internal\").db._document(e._from), edge: e});});}if (vertex.name === \"Eve\") {config.datasource.getOutEdges(vertex).forEach(function (e) {connections.push({vertex: require(\"internal\").db._document(e._to), edge: e});});}return connections;"

filter_func="if (vertex.name === \"Bob\" ||     vertex.name === \"Charlie\") {  return \"exclude\";}return;"

Unfortunately the page doesn't seem to contain an example for sort_func.

Due to the limitation of ArangoDB's REST API, there is no easy way to translate these capabilities to be more Pythonic, which is why I left the parameters as they are to take pure javascript strings.

Let me know if you have anymore questions.

Thanks,
Joohwan

@alexandropov
Copy link

alexandropov commented Oct 6, 2016

what's the purpose of each functions? i m still finding hard to undersand,
how do i traverse predefined graph paths in python?

@joowani
Copy link
Contributor

joowani commented Oct 6, 2016

Hi Alexandropov,

Have you checked out the documentation? It explains what each function does to some extent.
If you still have unresolved questions you will have to direct them to ArangoDB team. Python-arango is simply a driver that pipes all the inputs to ArangoDB's REST API, and I'm afraid my knowledge on the internals is rather limited.

You may not need these functions at all, however. What are you trying to achieve exactly? could you give me an example with edges + vertices and how you want to traverse them in detail?

Thanks,
Joohwan

@joowani
Copy link
Contributor

joowani commented Oct 16, 2016

Closing this out since I haven't heard back from you for a while now. Let me know if you have any other questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants