Пример #1
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)
Пример #2
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