public class GraphLoader extends Object
| Modifier and Type | Method and Description |
|---|---|
static <V,E> Graph<V,E> |
loadGraph(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(String vertexFilePath,
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<String,String> |
loadUndirectedGraphEdgeListFile(String path,
int numVertices,
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<String,String> |
loadUndirectedGraphEdgeListFile(String path,
int numVertices,
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<String,Double> |
loadWeightedEdgeListFile(String path,
int numVertices,
String delim,
boolean directed,
boolean allowMultipleEdges,
String... ignoreLinesStartingWith)
Method for loading a weighted graph from an edge list file, where each edge (inc.
|
static Graph<String,Double> |
loadWeightedEdgeListFile(String path,
int numVertices,
String delim,
boolean directed,
String... ignoreLinesStartingWith)
Method for loading a weighted graph from an edge list file, where each edge (inc.
|
public static Graph<String,String> loadUndirectedGraphEdgeListFile(String path, int numVertices, String delim) throws 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 graphIOException - if file cannot be readpublic static Graph<String,String> loadUndirectedGraphEdgeListFile(String path, int numVertices, String delim, boolean allowMultipleEdges) throws 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.IOException - if file cannot be readpublic static Graph<String,Double> loadWeightedEdgeListFile(String path, int numVertices, String delim, boolean directed, String... ignoreLinesStartingWith) throws 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 "#"IOExceptionpublic static Graph<String,Double> loadWeightedEdgeListFile(String path, int numVertices, String delim, boolean directed, boolean allowMultipleEdges, String... ignoreLinesStartingWith) throws 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 "#"IOExceptionpublic static <V,E> Graph<V,E> loadGraph(String path, EdgeLineProcessor<E> lineProcessor, VertexFactory<V> vertexFactory, int numVertices, boolean allowMultipleEdges) throws 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 notIOExceptionpublic static <V,E> Graph<V,E> loadGraph(String vertexFilePath, String edgeFilePath, VertexLoader<V> vertexLoader, EdgeLineProcessor<E> edgeLineProcessor, boolean allowMultipleEdges) throws 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 edgesIOExceptionCopyright © 2016. All Rights Reserved.