Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getReader(fileformat, **kwargs):
#define your [edgelist] reader here:
readers = {
Format.METIS: METISGraphReader(),
Format.GraphML: GraphMLReader(),
Format.GEXF: GEXFReader(),
Format.SNAP: EdgeListReader('\t',0,'#',False),
Format.EdgeListCommaOne: EdgeListReader(',',1,),
Format.EdgeListSpaceOne: EdgeListReader(' ',1),
Format.EdgeListSpaceZero: EdgeListReader(' ',0),
Format.EdgeListTabOne: EdgeListReader('\t',1),
Format.EdgeListTabZero: EdgeListReader('\t',0),
Format.LFR: EdgeListReader('\t',1),
Format.KONECT: KONECTGraphReader(' '),
Format.GML: GMLGraphReader(),
Format.GraphToolBinary: GraphToolBinaryReader(),
Format.MAT: MatReader()
}
try:
# special case for custom Edge Lists
if fileformat == Format.EdgeList:
if kwargs["continuous"] == False:
kwargs["firstNode"] = 0
reader = EdgeListReader(**kwargs)
else:
reader = readers[fileformat]#(**kwargs)
except Exception or KeyError:
raise Exception("unrecognized format/format not supported as input: {0}".format(fileformat))
return reader
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:
def getReader(fileformat, **kwargs):
#define your [edgelist] reader here:
readers = {
Format.METIS: METISGraphReader(),
Format.GraphML: GraphMLReader(),
Format.GEXF: GEXFReader(),
Format.SNAP: EdgeListReader('\t',0,'#',False),
Format.EdgeListCommaOne: EdgeListReader(',',1,),
Format.EdgeListSpaceOne: EdgeListReader(' ',1),
Format.EdgeListSpaceZero: EdgeListReader(' ',0),
Format.EdgeListTabOne: EdgeListReader('\t',1),
Format.EdgeListTabZero: EdgeListReader('\t',0),
Format.LFR: EdgeListReader('\t',1),
Format.KONECT: KONECTGraphReader(' '),
Format.GML: GMLGraphReader(),
Format.GraphToolBinary: GraphToolBinaryReader(),
Format.MAT: MatReader()
}
try:
# special case for custom Edge Lists
if fileformat == Format.EdgeList:
if kwargs["continuous"] == False:
kwargs["firstNode"] = 0
reader = EdgeListReader(**kwargs)
else:
reader = readers[fileformat]#(**kwargs)
except Exception or KeyError:
raise Exception("unrecognized format/format not supported as input: {0}".format(fileformat))
return reader
def getReader(fileformat, **kwargs):
#define your [edgelist] reader here:
readers = {
Format.METIS: METISGraphReader(),
Format.GraphML: GraphMLReader(),
Format.GEXF: GEXFReader(),
Format.SNAP: EdgeListReader('\t',0,'#',False),
Format.EdgeListCommaOne: EdgeListReader(',',1,),
Format.EdgeListSpaceOne: EdgeListReader(' ',1),
Format.EdgeListSpaceZero: EdgeListReader(' ',0),
Format.EdgeListTabOne: EdgeListReader('\t',1),
Format.EdgeListTabZero: EdgeListReader('\t',0),
Format.LFR: EdgeListReader('\t',1),
Format.KONECT: KONECTGraphReader(' '),
Format.GML: GMLGraphReader(),
Format.GraphToolBinary: GraphToolBinaryReader(),
Format.MAT: MatReader()
}
try:
# special case for custom Edge Lists
if fileformat == Format.EdgeList:
if kwargs["continuous"] == False:
kwargs["firstNode"] = 0
reader = EdgeListReader(**kwargs)
else:
reader = readers[fileformat]#(**kwargs)
except Exception or KeyError:
raise Exception("unrecognized format/format not supported as input: {0}".format(fileformat))
return reader
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
def getReader(fileformat, **kwargs):
#define your [edgelist] reader here:
readers = {
Format.METIS: METISGraphReader(),
Format.GraphML: GraphMLReader(),
Format.GEXF: GEXFReader(),
Format.SNAP: EdgeListReader('\t',0,'#',False),
Format.EdgeListCommaOne: EdgeListReader(',',1,),
Format.EdgeListSpaceOne: EdgeListReader(' ',1),
Format.EdgeListSpaceZero: EdgeListReader(' ',0),
Format.EdgeListTabOne: EdgeListReader('\t',1),
Format.EdgeListTabZero: EdgeListReader('\t',0),
Format.LFR: EdgeListReader('\t',1),
Format.KONECT: KONECTGraphReader(' '),
Format.GML: GMLGraphReader(),
Format.GraphToolBinary: GraphToolBinaryReader(),
Format.MAT: MatReader()
}
try:
# special case for custom Edge Lists
if fileformat == Format.EdgeList:
if kwargs["continuous"] == False:
kwargs["firstNode"] = 0
reader = EdgeListReader(**kwargs)
else:
reader = readers[fileformat]#(**kwargs)
except Exception or KeyError:
raise Exception("unrecognized format/format not supported as input: {0}".format(fileformat))
def getReader(fileformat, **kwargs):
#define your [edgelist] reader here:
readers = {
Format.METIS: METISGraphReader(),
Format.GraphML: GraphMLReader(),
Format.GEXF: GEXFReader(),
Format.SNAP: EdgeListReader('\t',0,'#',False),
Format.EdgeListCommaOne: EdgeListReader(',',1,),
Format.EdgeListSpaceOne: EdgeListReader(' ',1),
Format.EdgeListSpaceZero: EdgeListReader(' ',0),
Format.EdgeListTabOne: EdgeListReader('\t',1),
Format.EdgeListTabZero: EdgeListReader('\t',0),
Format.LFR: EdgeListReader('\t',1),
Format.KONECT: KONECTGraphReader(' '),
Format.GML: GMLGraphReader(),
Format.GraphToolBinary: GraphToolBinaryReader(),
Format.MAT: MatReader()
}
try:
# special case for custom Edge Lists
if fileformat == Format.EdgeList:
if kwargs["continuous"] == False:
kwargs["firstNode"] = 0
reader = EdgeListReader(**kwargs)
else:
reader = readers[fileformat]#(**kwargs)
except Exception or KeyError:
def getReader(fileformat, **kwargs):
#define your [edgelist] reader here:
readers = {
Format.METIS: METISGraphReader(),
Format.GraphML: GraphMLReader(),
Format.GEXF: GEXFReader(),
Format.SNAP: EdgeListReader('\t',0,'#',False),
Format.EdgeListCommaOne: EdgeListReader(',',1,),
Format.EdgeListSpaceOne: EdgeListReader(' ',1),
Format.EdgeListSpaceZero: EdgeListReader(' ',0),
Format.EdgeListTabOne: EdgeListReader('\t',1),
Format.EdgeListTabZero: EdgeListReader('\t',0),
Format.LFR: EdgeListReader('\t',1),
Format.KONECT: KONECTGraphReader(' '),
Format.GML: GMLGraphReader(),
Format.GraphToolBinary: GraphToolBinaryReader(),
Format.MAT: MatReader()
}
try:
# special case for custom Edge Lists
if fileformat == Format.EdgeList:
if kwargs["continuous"] == False:
kwargs["firstNode"] = 0
reader = EdgeListReader(**kwargs)
else:
#define your [edgelist] reader here:
readers = {
Format.METIS: METISGraphReader(),
Format.GraphML: GraphMLReader(),
Format.GEXF: GEXFReader(),
Format.SNAP: EdgeListReader('\t',0,'#',False),
Format.EdgeListCommaOne: EdgeListReader(',',1,),
Format.EdgeListSpaceOne: EdgeListReader(' ',1),
Format.EdgeListSpaceZero: EdgeListReader(' ',0),
Format.EdgeListTabOne: EdgeListReader('\t',1),
Format.EdgeListTabZero: EdgeListReader('\t',0),
Format.LFR: EdgeListReader('\t',1),
Format.KONECT: KONECTGraphReader(' '),
Format.GML: GMLGraphReader(),
Format.GraphToolBinary: GraphToolBinaryReader(),
Format.MAT: MatReader()
}
try:
# special case for custom Edge Lists
if fileformat == Format.EdgeList:
if kwargs["continuous"] == False:
kwargs["firstNode"] = 0
reader = EdgeListReader(**kwargs)
else:
reader = readers[fileformat]#(**kwargs)
except Exception or KeyError:
raise Exception("unrecognized format/format not supported as input: {0}".format(fileformat))
return reader