org.javanetworkanalyzer.graphcreators
Class WeightedGraphCreator<V extends VId,E extends Edge>

java.lang.Object
  extended by org.javanetworkanalyzer.graphcreators.GraphCreator<V,E>
      extended by org.javanetworkanalyzer.graphcreators.WeightedGraphCreator<V,E>

public class WeightedGraphCreator<V extends VId,E extends Edge>
extends GraphCreator<V,E>

Creates weighted JGraphT graphs from a csv file produced by OrbisGIS.

Author:
Adam Gouge

Field Summary
protected static int weightFieldIndex
          Weight index.
 
Fields inherited from class org.javanetworkanalyzer.graphcreators.GraphCreator
DIRECTED, DOUBLE_QUOTES, edgeClass, EMPTY_STRING, END_NODE, endNodeIndex, orientation, REVERSED, SEPARATOR, START_NODE, startNodeIndex, UNDIRECTED, vertexClass
 
Constructor Summary
WeightedGraphCreator(String csvFile, int orientation, Class<? extends V> vertexClass, Class<? extends E> edgeClass, String weightField)
          Initializes a new WeightedGraphCreator.
 
Method Summary
protected  KeyedGraph<V,E> initializeGraph()
          Initializes a graph.
protected  void initializeIndices(Scanner scanner)
          Initialize the start node, end node, and weight indices by reading the first line of the csv file.
protected  E loadEdge(String[] row, KeyedGraph<V,E> graph, boolean reverse)
          Loads a weighted edge into the graph.
 WeightedKeyedGraph<V,E> loadGraph()
          Returns a new graph from a csv file produced in OrbisGIS as the output.edges table given by ST_Graph.
 
Methods inherited from class org.javanetworkanalyzer.graphcreators.GraphCreator
deleteDoubleQuotes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

weightFieldIndex

protected static int weightFieldIndex
Weight index.

Constructor Detail

WeightedGraphCreator

public WeightedGraphCreator(String csvFile,
                            int orientation,
                            Class<? extends V> vertexClass,
                            Class<? extends E> edgeClass,
                            String weightField)
Initializes a new WeightedGraphCreator.

Parameters:
csvFile - CSV file containing the edge information.
weightField - The weight column name.
orientation - The desired graph orientation.
Method Detail

loadGraph

public WeightedKeyedGraph<V,E> loadGraph()
                                                           throws FileNotFoundException,
                                                                  NoSuchMethodException
Description copied from class: GraphCreator
Returns a new graph from a csv file produced in OrbisGIS as the output.edges table given by ST_Graph.

Overrides:
loadGraph in class GraphCreator<V extends VId,E extends Edge>
Returns:
The graph.
Throws:
FileNotFoundException
NoSuchMethodException

initializeIndices

protected void initializeIndices(Scanner scanner)
Initialize the start node, end node, and weight indices by reading the first line of the csv file.

Overrides:
initializeIndices in class GraphCreator<V extends VId,E extends Edge>
Parameters:
scanner - The scanner that will read the first line of the csv file.

initializeGraph

protected KeyedGraph<V,E> initializeGraph()
                                                            throws NoSuchMethodException
Description copied from class: GraphCreator
Initializes a graph.

Overrides:
initializeGraph in class GraphCreator<V extends VId,E extends Edge>
Returns:
The newly initialized graph
Throws:
NoSuchMethodException - If the vertex class does not have a constructor with just an Integer parameter.

loadEdge

protected E loadEdge(String[] row,
                     KeyedGraph<V,E> graph,
                     boolean reverse)
Loads a weighted edge into the graph.

Overrides:
loadEdge in class GraphCreator<V extends VId,E extends Edge>
Parameters:
row - The row from which to load the edge.
graph - The graph to which the edges will be added.
reverse - true iff the edge orientation should be reversed.
Returns:
The newly loaded edge.


Copyright © 2014. All Rights Reserved.