I am a newbie in OrientDB. Currently I want to create the undirect Edge between 2 Vertexes, it looks like: Product A relates to Product B.
I am using Java API, blueprint.
Thank you.
aVertex.addEdge(endVertex, "label")
graph.addEdge(id, outVertex, inVertex, "label")
Either way, there are always an out and an in vertex
There is no way to create an undirected edges. In OrientDB, as in most graph databases in the market, edges always have a direction.
It is not a limitation, because you can traverse edges regardless their direction, using both() query operator or, in Java:
vertex.getEdges(Direction.BOTH, label)
Related
I know the networkx could provide the breadth-first search (bfs) results based on the control of depth. I am wondering is there a workaround so I can control the result with the number of edges? For example, I hope to get 10 edges around a node i by bfs. But I don't know what depth it could be.
The bfs controlled by the depth is something like
bfs = nx.bfs_edges(G, source=i, depth_limit=5)
I hope to use a function something like
bfs = nx.bfs_edges(G, source=i, number=k)
As I hope to find all the edges around a node. So it looks like the nx.edge_bfs is a better option? This function returns all the edges currently. Could we modify it somehow? I hope the source node can be located as center as possible, i.e., the yield edges could evenly around the source node.
After looking at the source code of nx.edge_bfs, it looks like this function itself returns an iterator which yields the edges surround the source node one by one. And it basically returns the surrounding edges like a circle.
It could be better if someone could confirm this. Here is the source link
I'm new using Graph Databases and I'm a little confused about the concept of From / To or In/Out in OrientDB.
Which is the best approach to define which Vertex is From and which is To? Or Both for example when is a relation of contact in social network.
In my opinion, the most part of this confusion comes from Apache TinkerPop notation for edges. OrientDB historically adopted TinkerPop as its graph API (some things are changing here, so in v 3.0 there will be a native document/graph API that does not depend on Apache TinkerPop API, but we will still maintain the support with TinkerPop 3.x) so the notation is the same.
Apache TinkerPop uses OUT/IN to define both edges connected to vertices and vertices connected to edges:
given a vertex, you have outgoing edges referenced by OUT and incoming edges referenced by IN (so far so good)
given an edge, it has the starting point (the vertex it comes from) identified by OUT (ouch!) and the end point (the vertex it goes to) identified by IN
And here come the problems: for a beginner, it's very natural to consider an edge traversal as an out + out:
vertex -out-> edge -out-> anotherVertex
but unfortunately it's WRONG!
The right way to do a straight edge traversal is out + in:
vertex -out-> edge -in-> anotherVertex
You can also traverse the edge backwards with an in + out.
As I wrote before, IMHO it's extremely unintuitive, at the beginning I also had problems with this. IMHO the best notation for edge connection would have been FROM/TO, instead of OUT/IN, but it's a standard now, so we cannot do much.
The only thing I can tell you is that it becomes natural with a little practice.
A separate consideration is for social networks and in general for edges that are not intended to have a direction (in a social network the direction of edges is not important, the fact that I'm your friend also implied that you are my friend). Apache TinkerPop does not have a concept of undirected edges, so you just have to use directed edges and ignore the direction when traversing them (eg. using the both() operator or BOTH direction)
I am working with orientDB v2.2.10 and I am trying to create edges of class "E" between vertices using the graph editor, my question is can create undirected edges between vertices and if yes how to do it via Java API
You can find documentation about graph Java API here:
http://orientdb.com/docs/last/Graph-Database-Tinkerpop.html
How would write a traversal in use Gremlin TinkerPop 3 to find all vertices that have no incoming edges?
As a follow up I also need to find a vertices that have no outgoing edges as well.
This is simpler than the below version
g.V().not(inE())
g.V().not(outE())
Keeping my original answer for reference
g.V().where(inE().count().is(eq(0)))
For 0 outgoing edges
g.V().where(outE().count().is(eq(0)))
I have a graph that I want to to query vertices (full text search) by text that might occur in any of the keys in each vertex. How to do that?
I use Titan 0.9.0-M2 and Tinkerpop 3. The indexing backend is Elasticsearch.
Let's say your index is called vertices, then you would do:
graph.indexQuery("vertices","v.*:term").vertices()
Here's an example over the Graph of the Gods:
gremlin> graph.indexQuery("edges", "e.*:loves").edges()*.getElement()*.value("reason")
==>loves waves
==>loves fresh breezes