Package es.uam.eps.ir.relison.io.graph
Class PajekGraphReader<U extends java.io.Serializable>
java.lang.Object
es.uam.eps.ir.relison.io.graph.PajekGraphReader<U>
- Type Parameters:
U
- Type of the users
- All Implemented Interfaces:
GraphReader<U>
public class PajekGraphReader<U extends java.io.Serializable> extends java.lang.Object implements GraphReader<U>
Reads a graph using the Pajek format:
Format:
*Vertices numVertices
vertexId1 "vertexLabel1"
vertexId2 "vertexLabel2"
...
vertexIdN "vertexLabelN"
*Edges or *Arcs numEdges
vertexId1.1 vertexId1.2 weight1
vertexId2.1 vertexId2.2 weight2
...
vertexIdM.1 vertexIdM.2 weightM
-
Field Summary
Fields Modifier and Type Field Description private boolean
directed
Indicates if the graph to read is directed (true) or not (false)private boolean
multigraph
Indicates if the graph to read is a multigraph (true) or not (false)private boolean
selfloops
Indicates if the graph to read allows autoloops (true) or not (false)private org.ranksys.formats.parsing.Parser<U>
uParser
Parser for reading the usersprivate boolean
weighted
Indicates if the graph to read is weighted (true) or not (false) -
Constructor Summary
Constructors Constructor Description PajekGraphReader(boolean multigraph, boolean directed, boolean weighted, boolean selfloops, org.ranksys.formats.parsing.Parser<U> uParser)
Constructor -
Method Summary
Modifier and Type Method Description Graph<U>
read(java.io.InputStream stream)
Given an input stream, reads a file from it (for reading embedded graphs in greater files).Graph<U>
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<U>
read(java.io.InputStream stream, boolean readWeights, boolean readTypes, Index<U> users)
Given an input stream, reads a file from it (for reading embedded graphs in greater files).Graph<U>
read(java.lang.String file)
Given a file, reads a graph.Graph<U>
read(java.lang.String file, boolean readWeights, boolean readTypes)
Given a file, reads a graph.Graph<U>
read(java.lang.String file, boolean readWeights, boolean readTypes, Index<U> users)
Given an file, reads a graph.
-
Field Details
-
multigraph
private final boolean multigraphIndicates if the graph to read is a multigraph (true) or not (false) -
directed
private final boolean directedIndicates if the graph to read is directed (true) or not (false) -
weighted
private final boolean weightedIndicates if the graph to read is weighted (true) or not (false) -
selfloops
private final boolean selfloopsIndicates if the graph to read allows autoloops (true) or not (false) -
uParser
Parser for reading the users
-
-
Constructor Details
-
PajekGraphReader
public PajekGraphReader(boolean multigraph, boolean directed, boolean weighted, boolean selfloops, org.ranksys.formats.parsing.Parser<U> uParser)Constructor- Parameters:
multigraph
- Indicates if the graph to read is a multigraph (true) or not (false)directed
- Indicates if the graph to read is directed (true) or not (false)weighted
- Indicates if the graph to read is weighted (true) or not (false)selfloops
- Indicates if the graph to read allows autoloops (true) or not (false)uParser
- Parser for reading the users
-
-
Method Details
-
read
Description copied from interface:GraphReader
Given a file, reads a graph.- Specified by:
read
in interfaceGraphReader<U extends java.io.Serializable>
- 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<U extends java.io.Serializable>
- 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<U extends java.io.Serializable>
- Parameters:
stream
- The input stream we read the graph from.- 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).- Specified by:
read
in interfaceGraphReader<U extends java.io.Serializable>
- 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.
-
read
public Graph<U> read(java.lang.String file, boolean readWeights, boolean readTypes, Index<U> users)Description copied from interface:GraphReader
Given an file, reads a graph.- Specified by:
read
in interfaceGraphReader<U extends java.io.Serializable>
- 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<U> read(java.io.InputStream stream, boolean readWeights, boolean readTypes, Index<U> 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<U extends java.io.Serializable>
- 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.
-