V
 the graph vertex typeE
 the graph edge typepublic class GraphWalk<V,E> extends Object implements GraphPath<V,E>
v0, e0, v1, e1, v2,....vk1, ek1, vk
, such that for 1<=i<=k<
, the edge
e_i
has endpoints v_(i1)
and v_i
. The class makes no assumptions with
respect to the shape of the walk: edges may be repeated, and the start and end point of the walk
may be different.
See http://mathworld.wolfram.com/Walk.html
GraphWalk is the default implementation of GraphPath
.
This class is implemented as a lightweight data structure; this class does not verify whether
the sequence of edges or the sequence of vertices provided during construction forms an actual
walk. It is the responsibility of the invoking class to provide correct input data.Modifier and Type  Field and Description 

protected List<E> 
edgeList 
protected V 
endVertex 
protected Graph<V,E> 
graph 
protected V 
startVertex 
protected List<V> 
vertexList 
protected double 
weight 
Constructor and Description 

GraphWalk(Graph<V,E> graph,
List<V> vertexList,
double weight)
Creates a walk defined by a sequence of vertices.

GraphWalk(Graph<V,E> graph,
V startVertex,
V endVertex,
List<E> edgeList,
double weight)
Creates a walk defined by a sequence of edges.

GraphWalk(Graph<V,E> graph,
V startVertex,
V endVertex,
List<V> vertexList,
List<E> edgeList,
double weight)
Creates a walk defined by both a sequence of edges and a sequence of vertices.

Modifier and Type  Method and Description 

List<E> 
getEdgeList()
Returns the edges making up the path.

V 
getEndVertex()
Returns the end vertex in the path.

Graph<V,E> 
getGraph()
Returns the graph over which this path is defined.

int 
getLength()
Returns the length of the path, measured in the number of edges.

V 
getStartVertex()
Returns the start vertex in the path.

List<V> 
getVertexList()
Returns the path as a sequence of vertices.

double 
getWeight()
Returns the weight assigned to the path.

String 
toString() 
protected V startVertex
protected V endVertex
protected double weight
public GraphWalk(Graph<V,E> graph, V startVertex, V endVertex, List<E> edgeList, double weight)
graph
 the graphstartVertex
 the starting vertexendVertex
 the last vertex of the pathedgeList
 the list of edges of the pathweight
 the total weight of the pathpublic GraphWalk(Graph<V,E> graph, List<V> vertexList, double weight)
graph
 the graphvertexList
 the list of vertices of the pathweight
 the total weight of the pathpublic GraphWalk(Graph<V,E> graph, V startVertex, V endVertex, List<V> vertexList, List<E> edgeList, double weight)
graph
 the graphstartVertex
 the starting vertexendVertex
 the last vertex of the pathvertexList
 the list of vertices of the pathedgeList
 the list of edges of the pathweight
 the total weight of the pathpublic Graph<V,E> getGraph()
GraphPath
public V getStartVertex()
GraphPath
getStartVertex
in interface GraphPath<V,E>
public V getEndVertex()
GraphPath
getEndVertex
in interface GraphPath<V,E>
public List<E> getEdgeList()
GraphPath
GraphPath.getVertexList()
.
Whether or not the returned edge list is modifiable depends on the path implementation.
getEdgeList
in interface GraphPath<V,E>
public List<V> getVertexList()
GraphPath
getVertexList
in interface GraphPath<V,E>
public double getWeight()
GraphPath
public int getLength()
GraphPath
Copyright © 2017. All rights reserved.