helix.graph.algo
Class Cloner

java.lang.Object
  extended by helix.graph.algo.Cloner

public class Cloner
extends Object

a class to duplicate graphs or parts of graph


Method Summary
static Graph cloneGraph(Graph src)
          clone a graph completely same as subGraph(g, g.vertices())
static Vertex duplicateVertex(Graph graph, Vertex v)
          duplicate a single vertex in a graph
note: this is quicker than calling duplicateVertices with a singleton
-1- duplicate vertex v to copy(v) -2- foreach edge (v, u) createEdge(copy(v), u)
static GSet<Vertex> duplicateVertices(Graph graph, GSet<Vertex> vertices)
          duplicate a set of vertices within the same graph
-1- duplicate each vertex v in vertices to copy(v) -2- foreach vertex v in vertices foreach edge (v, u) createEdge(copy(v), u') with u' = (hasCopy(u) ? copy(u) : u)
static Graph subGraph(Graph src, Iterable<Vertex> vertices)
          make a subgraph from graph restricted to given vertices
static Graph union(Graph g1, Graph g2)
          make union of two disjoints graphs
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

subGraph

public static Graph subGraph(Graph src,
                             Iterable<Vertex> vertices)
make a subgraph from graph restricted to given vertices


cloneGraph

public static Graph cloneGraph(Graph src)
clone a graph completely same as subGraph(g, g.vertices())


union

public static Graph union(Graph g1,
                          Graph g2)
make union of two disjoints graphs


duplicateVertices

public static GSet<Vertex> duplicateVertices(Graph graph,
                                             GSet<Vertex> vertices)
duplicate a set of vertices within the same graph
-1- duplicate each vertex v in vertices to copy(v) -2- foreach vertex v in vertices foreach edge (v, u) createEdge(copy(v), u') with u' = (hasCopy(u) ? copy(u) : u)

Parameters:
graph - Graph to modify
vertices - subset of vertices in graph
Returns:
set of newly created vertices

duplicateVertex

public static Vertex duplicateVertex(Graph graph,
                                     Vertex v)
duplicate a single vertex in a graph
note: this is quicker than calling duplicateVertices with a singleton
-1- duplicate vertex v to copy(v) -2- foreach edge (v, u) createEdge(copy(v), u)

Parameters:
graph - Graph to modify
v - Vertex to duplicate
Returns:
newly created vertex (copy(v))