Routify Documentation
Loading...
Searching...
No Matches
ch.routify.graph.CustomGraph< V, E > Class Template Reference
Inheritance diagram for ch.routify.graph.CustomGraph< V, E >:
[legend]
Collaboration diagram for ch.routify.graph.CustomGraph< V, E >:
[legend]

Public Member Functions

 CustomGraph (Class<? extends E > edgeClass)
 
addEdge (V sourceVertex, V targetVertex)
 
CustomVertex nearestVertex (V from) throws Exception
 
void exportGexf () throws IOException, XMLStreamException, FactoryConfigurationError, SaxonApiException
 
void exportGexf (OutputStream out) throws IOException, XMLStreamException, FactoryConfigurationError, SaxonApiException
 
void prune ()
 
void mergeVertices (V v1, V v2) throws Exception
 

Detailed Description

A generic class that extends SimpleDirectedWeightedGraph to manage and manipulate graphs. It provides functionalities such as adding edges, finding the nearest vertex, exporting the graph in GEXF format, and cleaning up disjoint sets.

Parameters
<V>the vertex class, which should extend CustomVertex
<E>the edge class, which should extend CustomEdge
Author
Alexander Eggerth
Version
1.0

Constructor & Destructor Documentation

◆ CustomGraph()

ch.routify.graph.CustomGraph< V, E >.CustomGraph ( Class<? extends E > edgeClass)
inline

Constructs a CustomGraph with the specified edge class.

Parameters
edgeClassthe class of edges to be used in the graph

Member Function Documentation

◆ addEdge()

E ch.routify.graph.CustomGraph< V, E >.addEdge ( V sourceVertex,
V targetVertex )
inline

Adds an edge between source and target vertices. Prints a message if either vertex is null.

Parameters
sourceVertexthe source vertex of the edge
targetVertexthe target vertex of the edge
Returns
the added edge, or null if no edge was added

◆ exportGexf() [1/2]

void ch.routify.graph.CustomGraph< V, E >.exportGexf ( ) throws IOException, XMLStreamException, FactoryConfigurationError, SaxonApiException
inline

Exports the graph to a GEXF file with a default filename based on the current date.

Exceptions
IOExceptionif an I/O error occurs
XMLStreamExceptionif an error occurs while processing the XML
FactoryConfigurationErrorif a configuration error occurs
SaxonApiExceptionif an error occurs while using the Saxon API

◆ exportGexf() [2/2]

void ch.routify.graph.CustomGraph< V, E >.exportGexf ( OutputStream out) throws IOException, XMLStreamException, FactoryConfigurationError, SaxonApiException
inline

Exports the graph to a GEXF file using a custom output stream.

Parameters
outthe output stream to which the graph is exported
Exceptions
IOExceptionif an I/O error occurs
XMLStreamExceptionif an error occurs while processing the XML
FactoryConfigurationErrorif a configuration error occurs
SaxonApiExceptionif an error occurs while using the Saxon API

◆ mergeVertices()

void ch.routify.graph.CustomGraph< V, E >.mergeVertices ( V v1,
V v2 ) throws Exception
inline

◆ nearestVertex()

CustomVertex ch.routify.graph.CustomGraph< V, E >.nearestVertex ( V from) throws Exception
inline

Finds the nearest vertex to the given vertex.

Parameters
fromthe vertex from which to search
Returns
the nearest vertex to the specified vertex
Exceptions
Exceptionif the nearest vertex is more than 500 meters away

◆ prune()

void ch.routify.graph.CustomGraph< V, E >.prune ( )
inline

Prunes the graph to retain only the nodes belonging to its largest connected component. This method operates in several steps:

  1. Identify all connected components within the graph.
  2. Determine the largest connected component based on the number of nodes.
  3. Remove all nodes (and associated edges) not belonging to the largest connected component.

After execution, the graph will only contain nodes and edges that are part of the largest connected component. This method can significantly alter the graph structure and should be used with caution.

Exceptions
RuntimeExceptionIf no connected components can be found in the graph, indicating an empty or improperly initialized graph.

The documentation for this class was generated from the following file: