Undirected edges in orientDB - orientdb

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

Related

Graphx :Edit the graph and add the vertex and Edges

I'm new to Graphx and doing some research, where I have to map the property graph model to hadoop. I have successfully created the graph by creating Vertex and edge RDD.Now I want to edit my graph by adding vertex at position X and the add a edge at position X-1 and X+1.
I have read multiple documents which says graphs are immutable, but there is an option of subgraph but according to me it is used only to eliminate certain vertex and edges.
Can some one guide me is there any way to edit the graphs ?

OrientDB Edge From To Confusion

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)

How can I create the undirect Edge in OrientDB 2.2

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)

How to find all vertices that have no incoming edges in TinkerPop 3?

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)))

How to query all values in vertices using elasticsearch in Tinkerpop3 graph

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