示例#1
0
 def test_readAndWrite(self):
     #		from networkit.graphio import METISGraphReader
     from _NetworKit import METISGraphReader
     from _NetworKit import METISGraphWriter
     w = METISGraphWriter()
     w.write(self.g, "output/metis_test.graph")
     self.assertTrue(os.path.isfile("output/metis_test.graph"))
     r = METISGraphReader()
     testg = r.read("output/metis_test.graph")
     self.assertEqual(self.g.numberOfNodes(), testg.numberOfNodes())
     self.assertEqual(self.g.numberOfEdges(), testg.numberOfEdges())
示例#2
0
	def test_readAndWrite(self):
#		from networkit.graphio import METISGraphReader
		from _NetworKit import METISGraphReader
		from _NetworKit import METISGraphWriter
		w = METISGraphWriter()
		w.write(self.g, "output/metis_test.graph")
		self.assertTrue(os.path.isfile("output/metis_test.graph"))
		r = METISGraphReader()
		testg = r.read("output/metis_test.graph")
		self.assertEqual(self.g.numberOfNodes(), testg.numberOfNodes())
		self.assertEqual(self.g.numberOfEdges(), testg.numberOfEdges())
示例#3
0
def getWriter(fileformat, *kargs, **kwargs):
    writers = {
        Format.METIS: METISGraphWriter(),
        Format.GraphML: GraphMLWriter(),
        Format.GEXF: GEXFWriter(),
        Format.SNAP: SNAPGraphWriter(),
        Format.EdgeListCommaOne: EdgeListWriter(
            ',',
            1,
        ),
        Format.EdgeListSpaceOne: EdgeListWriter(' ', 1),
        Format.EdgeListSpaceZero: EdgeListWriter(' ', 0),
        Format.EdgeListTabOne: EdgeListWriter('\t', 1),
        Format.EdgeListTabZero: EdgeListWriter('\t', 0),
        Format.GraphViz: DotGraphWriter(),
        Format.DOT: DotGraphWriter(),
        Format.GML: GMLGraphWriter(),
        Format.LFR: EdgeListWriter('\t', 1),
        Format.GraphToolBinary: GraphToolBinaryWriter(),
        Format.MAT: MatWriter(),
        Format.ThrillBinary: ThrillGraphBinaryWriter(),
        Format.NetworkitBinary: NetworkitBinaryWriter()
    }

    # special case for custom Edge Lists
    if fileformat == Format.EdgeList:
        return EdgeListWriter(*kargs, **kwargs)

    else:
        if fileformat not in writers:
            raise Exception(
                "format {0} currently not supported".format(fileformat))

        return writers[fileformat]  #(**kwargs)
示例#4
0
def getWriter(fileformat, **kwargs):
	writers =	{
			Format.METIS:			METISGraphWriter(),
			Format.GraphML:			GraphMLWriter(),
			Format.GEXF:			GEXFWriter(),
#			Format.SNAP:			EdgeListWriter('\t',0,'#',False),
			Format.EdgeListCommaOne:	EdgeListWriter(',',1,),
			Format.EdgeListSpaceOne:	EdgeListWriter(' ',1),
			Format.EdgeListSpaceZero:	EdgeListWriter(' ',0),
			Format.EdgeListTabOne:		EdgeListWriter('\t',1),
			Format.EdgeListTabZero:		EdgeListWriter('\t',0),
			Format.GraphViz:		DotGraphWriter(),
			Format.DOT:			DotGraphWriter(),
			Format.GML:			GMLGraphWriter(),
			Format.LFR:			EdgeListWriter('\t',1),
			Format.GraphToolBinary:		GraphToolBinaryWriter()
			}
	try:
		# special case for custom Edge Lists
		if fileformat == Format.EdgeList:
			writer = EdgeListWriter(kwargs['separator'],kwargs['firstNode'])
		else:
			writer = writers[fileformat]#(**kwargs)
	except KeyError:
		raise Exception("format {0} currently not supported".format(fileformat))
	return writer