ch.bfh.algo.example
Class GraphExample3

java.lang.Object
  extended by ch.bfh.algo.example.GraphExample3

public class GraphExample3
extends Object

The class GraphExample3 contains an example of the ch.bfh.algo.Graph interface, using the Factory Pattern to have specialized Vertices. This example contains the creation of one graph containing 10 vertices and 12 edges. The vertices have two new properties visited which is used durring the algorithm and connectedComponentNumber which contains the number of the connencted component containing this vertex. They are implemented using another class and the Factory Pattern to create new instances without changing anything in the graph classes.

Version:
1.0
Author:
Emmanuel Benoist

Constructor Summary
GraphExample3()
           
 
Method Summary
 Graph<Integer,String> constructDirectedGraph()
          The constructDirectedGraph method is used to initialize a default directed Graph.
static Sequence<Position<String>> dfsTraversal(Graph<Integer,String> g, List<Position<String>> vertices)
          The dfsTraversal is an example of the possible implementation of a Depth First Search traversal of a Graph.
static void main(String[] args)
           
static void reverseAllEdges(Graph<Integer,String> g)
           
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphExample3

public GraphExample3()
Method Detail

dfsTraversal

public static Sequence<Position<String>> dfsTraversal(Graph<Integer,String> g,
                                                      List<Position<String>> vertices)
The dfsTraversal is an example of the possible implementation of a Depth First Search traversal of a Graph. In this case, we use the DecoratedVertex to store inside each vertex if it has been visited.

Returns:
a Sequence value

reverseAllEdges

public static void reverseAllEdges(Graph<Integer,String> g)

constructDirectedGraph

public Graph<Integer,String> constructDirectedGraph()
The constructDirectedGraph method is used to initialize a default directed Graph. The returned graph contains 10 vertices and 12 directed edges.

Returns:
a Graph value

run

public void run()

main

public static void main(String[] args)