Class GexfGraphWriter<V,E>
- java.lang.Object
-
- com.jgalgo.io.GexfGraphWriter<V,E>
-
- Type Parameters:
V
- the vertices typeE
- the edges type
- All Implemented Interfaces:
GraphWriter<V,E>
public final class GexfGraphWriter<V,E> extends Object
Write a graph in 'GEXF' format.GEXF is an XML-based format for graphs. Both directed and undirected graphs are supported, along with mixed graphs (some edges are directed while others are undirected) although the
Graph
does not supported mixed graphs (therefore the writer also doesn't support it). The format support graphs with vertices and edges of any type, as long as they can be written as an XML attribute string. The format also support multiple weights for vertices and edges, of any primitive Java type (int
,long
,double
,boolean
, ect.),String
,Date
,URI
,BigInteger
,BigDecimal
, along with 'list' (arrays) of any of the above exceptDate
andURI
.When the writer writes a graph with weights, it will try to identify the type of weights and write them accordingly. For any of the primitive type weights containers such as
WeightsInt
,WeightsLong
,WeightsDouble
,WeightsBool
, ect., the writer will easily identify the primitive types. On the other hand, forWeightsObj
, the writer will try to identify the type of the weights by checking the type of the default value and the actual weights of the vertices/edges. If all weights (and default value if exists) are a boxed type of any primitive type, the writer will write the weights as the corresponding primitive type. If all weights areString
,Date
,URI
,BigInteger
,BigDecimal
, the writer will be able to identify the type of the weights and write them accordingly. If all weights are arrays of primitive types (such asint[]
,long[]
,double[]
,boolean[]
, ect.), or fastutil lists of primitive types (such asIntList
,LongList
,DoubleList
,BooleanList
, ect.), orList
of boxed primitive types (such asList<Integer>
,List<Long>
,List<Double>
,List<Boolean>
, ect.), the writer will write the weights 'list' (array) type of the primitive type (the reader will read them as arrays of primitives). If all weights are arrays ofString
,BigInteger
,BigDecimal
, orList
ofString
,BigInteger
,BigDecimal
, the writer will write the weights as 'list' (array) ofString
,BigInteger
,BigDecimal
respectively (the reader will read them as arrays of objects). Note thatnull
weights are not supported and will cause an exception to be thrown.The GEXF format support both self edges and parallel edges. The format documentation can be found here.
- Author:
- Barak Ugav
- See Also:
GexfGraphReader
-
-
Constructor Summary
Constructors Constructor Description GexfGraphWriter()
Create a new writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
writeGraph(Graph<V,E> graph, Writer writer)
Write a graph to an I/O writer.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.jgalgo.io.GraphWriter
writeGraph, writeGraph
-
-
-
-
Method Detail
-
writeGraph
public final void writeGraph(Graph<V,E> graph, Writer writer)
Description copied from interface:GraphWriter
Write a graph to an I/O writer.- Specified by:
writeGraph
in interfaceGraphWriter<V,E>
- Parameters:
graph
- a graphwriter
- an I/O writer to which the graph description will be written to
-
-