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);
}
}