Class GraphAlgorithms
java.lang.Object
jdg.graph.GraphAlgorithms
A small collection of graph algorithms
- Author:
- Luca Castelli Aleardi
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AdjacencyListGraphextractComponent(AdjacencyListGraph g1, int indexU, AdjacencyListGraph g2) Given two input graphs G1, G2 and a vertex U, extract a sub-graph from g2 as defined belowstatic AdjacencyListGraphextractSubGraph(AdjacencyListGraph g, boolean[] vertexExists) Given an input graph G, extract and return (a copy of) the induced sub-graph G', having a given sub-set of vertices
-
Constructor Details
-
GraphAlgorithms
public GraphAlgorithms()
-
-
Method Details
-
extractSubGraph
Given an input graph G, extract and return (a copy of) the induced sub-graph G', having a given sub-set of verticesRemark: the graph G is assumed to be undirected
- Parameters:
g- the input graphvertexExists- [] an array (boolean) saying whether a given node must appear in the sub-graph G'- Returns:
- the (induced) sub-graph G'
-
extractComponent
public static AdjacencyListGraph extractComponent(AdjacencyListGraph g1, int indexU, AdjacencyListGraph g2) Given two input graphs G1, G2 and a vertex U, extract a sub-graph from g2 as defined below-) first compute the connected component C1 containing U in G1 -) let S1 denote the vertex set of the component C1 -) extract from G2 the subgraph whose vertex set corresponds to S1
Remark: the graphs G1 and G2 are assumed to be undirected, and having the same number of nodes
- Parameters:
g1- first input graphindexU- index of a vertex in G1g2- second input graph- Returns:
- the (induced) sub-graph G'
-