Menu

[r66]: / ls / graph / serialize / DefaultGraphSerializer.java  Maximize  Restore  History

Download this file

38 lines (31 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package ls.graph.serialize;
import java.io.IOException;
import java.io.Writer;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.decorators.ConstantEdgeValue;
import edu.uci.ics.jung.graph.decorators.NumberEdgeValue;
import edu.uci.ics.jung.graph.decorators.VertexStringer;
import edu.uci.ics.jung.io.PajekNetWriter;
public class DefaultGraphSerializer implements GraphSerializer
{
private VertexStringer vertexStringer = null;
public DefaultGraphSerializer(VertexStringer vs)
{
super();
this.vertexStringer = vs;
}
public void serialize(Graph g, String filename) throws IOException
{
if (g == null) return;
PajekNetWriter writer = new PajekNetWriter();
NumberEdgeValue nev = new ConstantEdgeValue(1.0);
writer.save(g, filename,vertexStringer,nev);
}
public void serialize(Graph g, Writer w) throws IOException
{
if (g == null) return;
PajekNetWriter gw = new PajekNetWriter();
NumberEdgeValue nev = new ConstantEdgeValue(1.0);
gw.save(g, w,vertexStringer,nev);
}
}
MongoDB Logo MongoDB