public class GraphLoader
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <V,E> Graph<V,E> |
loadGraph(java.lang.String path,
EdgeLineProcessor<E> lineProcessor,
VertexFactory<V> vertexFactory,
int numVertices,
boolean allowMultipleEdges)
Load a graph into memory, using a given EdgeLineProcessor.
|
static <V,E> Graph<V,E> |
loadGraph(java.lang.String vertexFilePath,
java.lang.String edgeFilePath,
VertexLoader<V> vertexLoader,
EdgeLineProcessor<E> edgeLineProcessor,
boolean allowMultipleEdges)
Load graph, assuming vertices are in one file and edges are in another file.
|
static Graph<java.lang.String,java.lang.String> |
loadUndirectedGraphEdgeListFile(java.lang.String path,
int numVertices,
java.lang.String delim)
Simple method for loading an undirected graph, where the graph is represented by a edge list with one edge
per line with a delimiter in between
This method assumes that all lines in the file are of the form i<delim>j where i and j are integers
in range 0 to numVertices inclusive, and "loadUndirectedGraphEdgeListFile(String, int, String, boolean) with allowMultipleEdges = true. |
static Graph<java.lang.String,java.lang.String> |
loadUndirectedGraphEdgeListFile(java.lang.String path,
int numVertices,
java.lang.String delim,
boolean allowMultipleEdges)
Simple method for loading an undirected graph, where the graph is represented by a edge list with one edge
per line with a delimiter in between
This method assumes that all lines in the file are of the form i<delim>j where i and j are integers
in range 0 to numVertices inclusive, and " |
static Graph<java.lang.String,java.lang.Double> |
loadWeightedEdgeListFile(java.lang.String path,
int numVertices,
java.lang.String delim,
boolean directed,
boolean allowMultipleEdges,
java.lang.String... ignoreLinesStartingWith)
Method for loading a weighted graph from an edge list file, where each edge (inc.
|
static Graph<java.lang.String,java.lang.Double> |
loadWeightedEdgeListFile(java.lang.String path,
int numVertices,
java.lang.String delim,
boolean directed,
java.lang.String... ignoreLinesStartingWith)
Method for loading a weighted graph from an edge list file, where each edge (inc.
|
public static Graph<java.lang.String,java.lang.String> loadUndirectedGraphEdgeListFile(java.lang.String path, int numVertices, java.lang.String delim) throws java.io.IOException
i<delim>j
where i and j are integers
in range 0 to numVertices inclusive, and "loadUndirectedGraphEdgeListFile(String, int, String, boolean)
with allowMultipleEdges = true.path
- Path to the edge list filenumVertices
- number of vertices in the graphjava.io.IOException
- if file cannot be readpublic static Graph<java.lang.String,java.lang.String> loadUndirectedGraphEdgeListFile(java.lang.String path, int numVertices, java.lang.String delim, boolean allowMultipleEdges) throws java.io.IOException
i<delim>j
where i and j are integers
in range 0 to numVertices inclusive, and "path
- Path to the edge list filenumVertices
- number of vertices in the graphallowMultipleEdges
- If set to false, the graph will not allow multiple edges between any two vertices to exist. However,
checking for duplicates during graph loading can be costly, so use allowMultipleEdges=true when
possible.java.io.IOException
- if file cannot be readpublic static Graph<java.lang.String,java.lang.Double> loadWeightedEdgeListFile(java.lang.String path, int numVertices, java.lang.String delim, boolean directed, java.lang.String... ignoreLinesStartingWith) throws java.io.IOException
fromIndex<delim>toIndex<delim>edgeWeight
where <delim>
is the delimiter.
Note: this method calls loadWeightedEdgeListFile(String, int, String, boolean, boolean, String...)
with allowMultipleEdges = true.path
- Path to the edge list filenumVertices
- The number of vertices in the graphdelim
- The delimiter used in the file (typically: "," or " " etc)directed
- whether the edges should be treated as directed (true) or undirected (false)ignoreLinesStartingWith
- Starting characters for comment lines. May be null. For example: "//" or "#"java.io.IOException
public static Graph<java.lang.String,java.lang.Double> loadWeightedEdgeListFile(java.lang.String path, int numVertices, java.lang.String delim, boolean directed, boolean allowMultipleEdges, java.lang.String... ignoreLinesStartingWith) throws java.io.IOException
fromIndex<delim>toIndex<delim>edgeWeight
where <delim>
is the delimiter.path
- Path to the edge list filenumVertices
- The number of vertices in the graphdelim
- The delimiter used in the file (typically: "," or " " etc)directed
- whether the edges should be treated as directed (true) or undirected (false)allowMultipleEdges
- If set to false, the graph will not allow multiple edges between any two vertices to exist. However,
checking for duplicates during graph loading can be costly, so use allowMultipleEdges=true when
possible.ignoreLinesStartingWith
- Starting characters for comment lines. May be null. For example: "//" or "#"java.io.IOException
public static <V,E> Graph<V,E> loadGraph(java.lang.String path, EdgeLineProcessor<E> lineProcessor, VertexFactory<V> vertexFactory, int numVertices, boolean allowMultipleEdges) throws java.io.IOException
path
- Path to the file containing the edges, one per linelineProcessor
- EdgeLineProcessor used to convert lines of text into a graph (or null for comment lines etc)vertexFactory
- Used to create verticesnumVertices
- number of vertices in the graphallowMultipleEdges
- whether the graph should allow multiple edges between a given pair of vertices or notjava.io.IOException
public static <V,E> Graph<V,E> loadGraph(java.lang.String vertexFilePath, java.lang.String edgeFilePath, VertexLoader<V> vertexLoader, EdgeLineProcessor<E> edgeLineProcessor, boolean allowMultipleEdges) throws java.io.IOException
vertexFilePath
- Path to file containing vertices, one per lineedgeFilePath
- Path to the file containing edges, one per linevertexLoader
- VertexLoader, for loading vertices from the fileedgeLineProcessor
- EdgeLineProcessor, converts text lines into edgesallowMultipleEdges
- whether the graph should allow (or filter out) multiple edgesjava.io.IOException