Package es.uam.eps.ir.relison.io.graph
Class BinaryGraphReader
java.lang.Object
es.uam.eps.ir.relison.io.graph.BinaryGraphReader
- All Implemented Interfaces:
GraphReader<java.lang.Long>
public class BinaryGraphReader extends java.lang.Object implements GraphReader<java.lang.Long>
Class for reading graph from binary files
-
Constructor Summary
Constructors Constructor Description BinaryGraphReader()
-
Method Summary
Modifier and Type Method Description Graph<java.lang.Long>
read(java.io.InputStream stream)
Given an input stream, reads a file from it (for reading embedded graphs in greater files).Graph<java.lang.Long>
read(java.io.InputStream stream, boolean readWeights, boolean readTypes)
Given an input stream, reads a file from it (for reading embedded graphs in greater files).Graph<java.lang.Long>
read(java.io.InputStream stream, boolean readWeights, boolean readTypes, Index<java.lang.Long> users)
Given an input stream, reads a file from it (for reading embedded graphs in greater files).Graph<java.lang.Long>
read(java.lang.String file)
Given a file, reads a graph.Graph<java.lang.Long>
read(java.lang.String file, boolean readWeights, boolean readTypes)
Given a file, reads a graph.Graph<java.lang.Long>
read(java.lang.String file, boolean readWeights, boolean readTypes, Index<java.lang.Long> users)
Given an file, reads a graph.private Graph<java.lang.Long>
readMultiGraph(java.io.InputStream stream, boolean directed, boolean weighted, boolean readWeights, boolean readTypes)
Reads a multigraph from an input stream reading a binary fileprivate Graph<java.lang.Long>
readMultiGraph(java.io.InputStream stream, boolean directed, boolean weighted, boolean readWeights, boolean readTypes, Index<java.lang.Long> users)
Reads a multigraph from an input stream reading a binary file.private Graph<java.lang.Long>
readSimpleGraph(java.io.InputStream stream, boolean directed, boolean weighted, boolean readWeights, boolean readTypes)
Reads a graph from an input stream reading a binary file.private Graph<java.lang.Long>
readSimpleGraph(java.io.InputStream stream, boolean directed, boolean weighted, boolean readWeights, boolean readTypes, Index<java.lang.Long> users)
Reads a graph from an input stream reading a binary file.
-
Constructor Details
-
BinaryGraphReader
public BinaryGraphReader()
-
-
Method Details
-
read
Description copied from interface:GraphReader
Given a file, reads a graph.- Specified by:
read
in interfaceGraphReader<java.lang.Long>
- Parameters:
file
- The file containing the nodes.- Returns:
- the graph if everything goes ok, null otherwise.
-
read
Description copied from interface:GraphReader
Given a file, reads a graph.- Specified by:
read
in interfaceGraphReader<java.lang.Long>
- Parameters:
file
- The file containing the graph.readWeights
- True if the file contains weights, false otherwise.readTypes
- True if the file contains types, false otherwise.- Returns:
- the graph if everything goes ok, null otherwise.
-
read
Description copied from interface:GraphReader
Given an input stream, reads a file from it (for reading embedded graphs in greater files). By default, assumes the graph contains information about weights, but not about types.- Specified by:
read
in interfaceGraphReader<java.lang.Long>
- Parameters:
stream
- The input stream we read the graph from.- Returns:
- the graph if everything goes ok, null otherwise.
-
read
public Graph<java.lang.Long> read(java.io.InputStream stream, boolean readWeights, boolean readTypes)Description copied from interface:GraphReader
Given an input stream, reads a file from it (for reading embedded graphs in greater files).- Specified by:
read
in interfaceGraphReader<java.lang.Long>
- Parameters:
stream
- The input stream we read the graph from.readWeights
- True if the file contains weights, false otherwise.readTypes
- True if the file contains graph types.- Returns:
- the graph if everything goes ok, null otherwise.
-
readMultiGraph
private Graph<java.lang.Long> readMultiGraph(java.io.InputStream stream, boolean directed, boolean weighted, boolean readWeights, boolean readTypes)Reads a multigraph from an input stream reading a binary file- Parameters:
stream
- the input streamdirected
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.readWeights
- true if weights have to be read.readTypes
- true if types have to be read.- Returns:
- the multigraph.
-
readSimpleGraph
private Graph<java.lang.Long> readSimpleGraph(java.io.InputStream stream, boolean directed, boolean weighted, boolean readWeights, boolean readTypes) throws java.io.IOExceptionReads a graph from an input stream reading a binary file.- Parameters:
stream
- the input stream.directed
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.readWeights
- true if weights have to be read.readTypes
- true if types have to be read.- Returns:
- the graph.
- Throws:
java.io.IOException
- if something fails during the reading.
-
read
public Graph<java.lang.Long> read(java.lang.String file, boolean readWeights, boolean readTypes, Index<java.lang.Long> users)Description copied from interface:GraphReader
Given an file, reads a graph.- Specified by:
read
in interfaceGraphReader<java.lang.Long>
- Parameters:
file
- The file containing the graph.readWeights
- True if the file contains weights, false otherwise.readTypes
- True if the file contains graph types.users
- An index containing the nodes in the network.- Returns:
- the graph if everything goes ok, null otherwise.
-
read
public Graph<java.lang.Long> read(java.io.InputStream stream, boolean readWeights, boolean readTypes, Index<java.lang.Long> users)Description copied from interface:GraphReader
Given an input stream, reads a file from it (for reading embedded graphs in greater files).- Specified by:
read
in interfaceGraphReader<java.lang.Long>
- Parameters:
stream
- The input stream we read the graph from.readWeights
- True if the file contains weights, false otherwise.readTypes
- True if the file contains graph types.users
- An index containing the nodes in the network.- Returns:
- the graph if everything goes ok, null otherwise.
-
readMultiGraph
private Graph<java.lang.Long> readMultiGraph(java.io.InputStream stream, boolean directed, boolean weighted, boolean readWeights, boolean readTypes, Index<java.lang.Long> users)Reads a multigraph from an input stream reading a binary file.- Parameters:
stream
- the input streamdirected
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.readWeights
- true if weights have to be read.readTypes
- true if types have to be read.users
- a user index.- Returns:
- the multigraph.
-
readSimpleGraph
private Graph<java.lang.Long> readSimpleGraph(java.io.InputStream stream, boolean directed, boolean weighted, boolean readWeights, boolean readTypes, Index<java.lang.Long> users) throws java.io.IOExceptionReads a graph from an input stream reading a binary file.- Parameters:
stream
- the input stream.directed
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.readWeights
- true if weights have to be read.readTypes
- true if types have to be read.users
- a user index.- Returns:
- the graph.
- Throws:
java.io.IOException
- if something fails during the reading.
-