Package es.uam.eps.ir.relison.io.graph
Class BinaryGraphWriter
java.lang.Object
es.uam.eps.ir.relison.io.graph.BinaryGraphWriter
- All Implemented Interfaces:
GraphWriter<java.lang.Long>
public class BinaryGraphWriter extends java.lang.Object implements GraphWriter<java.lang.Long>
Writes a graph into a binary file.
-
Constructor Summary
Constructors Constructor Description BinaryGraphWriter()
-
Method Summary
Modifier and Type Method Description boolean
write(Graph<java.lang.Long> graph, java.io.OutputStream file)
Writes a graph into an output stream.boolean
write(Graph<java.lang.Long> graph, java.io.OutputStream file, boolean writeWeights, boolean writeTypes)
Writes a graph into a output stream.boolean
write(Graph<java.lang.Long> graph, java.lang.String file)
Writes a graph into a file.boolean
write(Graph<java.lang.Long> graph, java.lang.String file, boolean writeWeights, boolean writeTypes)
Writes a graph into a file.private boolean
writeMulti(MultiGraph<java.lang.Long> graph, java.io.OutputStream file, boolean writeWeights, boolean writeTypes)
Writes a multigraph.private boolean
writeSimple(Graph<java.lang.Long> graph, java.io.OutputStream file, boolean writeWeights, boolean writeTypes)
Writes a simple graph (without multiedges)
-
Constructor Details
-
BinaryGraphWriter
public BinaryGraphWriter()
-
-
Method Details
-
write
Description copied from interface:GraphWriter
Writes a graph into a file. It writes the weights, but not the types- Specified by:
write
in interfaceGraphWriter<java.lang.Long>
- Parameters:
graph
- The graph we want to write.file
- The file.- Returns:
- true if everything went OK, false otherwise.
-
write
Description copied from interface:GraphWriter
Writes a graph into an output stream. It writes the weights, but not the types.- Specified by:
write
in interfaceGraphWriter<java.lang.Long>
- Parameters:
graph
- The graph we want to write.file
- The output stream.- Returns:
- true if everything went OK, false otherwise.
-
write
public boolean write(Graph<java.lang.Long> graph, java.lang.String file, boolean writeWeights, boolean writeTypes)Description copied from interface:GraphWriter
Writes a graph into a file. Simple graphs types are written, while multigraph types are not.- Specified by:
write
in interfaceGraphWriter<java.lang.Long>
- Parameters:
graph
- The graph we want to write.file
- The file.writeWeights
- Indicates if weights have to be written.writeTypes
- Indicates if types have to be written.- Returns:
- true if everything is ok, false otherwise.
-
write
public boolean write(Graph<java.lang.Long> graph, java.io.OutputStream file, boolean writeWeights, boolean writeTypes)Description copied from interface:GraphWriter
Writes a graph into a output stream. Simple graphs types are written, while multigraph types are not.- Specified by:
write
in interfaceGraphWriter<java.lang.Long>
- Parameters:
graph
- The graph we want to write.file
- The file.writeWeights
- Indicates if weights have to be written.writeTypes
- Indicates if types have to be written.- Returns:
- true if everything is ok, false otherwise.
-
writeMulti
private boolean writeMulti(MultiGraph<java.lang.Long> graph, java.io.OutputStream file, boolean writeWeights, boolean writeTypes) throws java.io.IOExceptionWrites a multigraph.- Parameters:
graph
- the multigraph to writefile
- the output stream where to write the graph.writeWeights
- true if weights have to be written.writeTypes
- true if types have to be written.- Returns:
- true if everything went ok, false if not.
- Throws:
java.io.IOException
- if something fails while writing
-
writeSimple
private boolean writeSimple(Graph<java.lang.Long> graph, java.io.OutputStream file, boolean writeWeights, boolean writeTypes) throws java.io.IOExceptionWrites a simple graph (without multiedges)- Parameters:
graph
- the graphfile
- the output stream where to write the graphwriteWeights
- true if weights have to be writtenwriteTypes
- true if types have to be written- Returns:
- true if everything went ok, false if not
- Throws:
java.io.IOException
- if something fails while writing.
-