The Property Graph
The property graph is a directed multigraph with user defined objects attached to each vertex and edge. A directed multigraph is a directed graph with potentially multiple parallel edges sharing the same source and destination vertex. The ability to support parallel edges simplifies modeling scenarios where there can be multiple relationships (e.g., co-worker and friend) between the same vertices. Each vertex is keyed by a unique 64-bit long identifier (VertexId). GraphX does not impose any ordering constraints on the vertex identifiers. Similarly, edges have corresponding source and destination vertex identifiers.
//create a vertices RDD as an City object instances
val vertices = Array(
(1L, City("Kazan", 55, 49)),
(2L, City("Moscow", 55, 37)),
(3L, City("Petresburg", 59, 30)))
val vericesRDD = sc.parallelize(vertices)
//create edges RDD
val edges = Array(Edge(1L, 2L, 810), Edge(1L, 3L, 1500), Edge(2L, 3L, 700));
val edgesRDD = sc.parallelize(edges)
//create a Graph
val graph = Graph(vericesRDD, edgesRDD)
//print all vertices of graph
graph.vertices.foreach(println)
//print all edges of graph
graph.edges.foreach(println)
//print edge triplets
graph.triplets.collect.foreach(println)