MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / write_gexf

Function write_gexf

easygraph/readwrite/gexf.py:18–50  ·  view source on GitHub ↗

Write G in GEXF format to path. "GEXF (Graph Exchange XML Format) is a language for describing complex networks structures, their associated data and dynamics" [1]_. Node attributes are checked according to the version of the GEXF schemas used for parameters which are not user defi

(G, path, encoding="utf-8", prettyprint=True, version="1.2draft")

Source from the content-addressed store, hash-verified

16
17
18def write_gexf(G, path, encoding="utf-8", prettyprint=True, version="1.2draft"):
19 """Write G in GEXF format to path.
20
21 "GEXF (Graph Exchange XML Format) is a language for describing
22 complex networks structures, their associated data and dynamics" [1]_.
23
24 Node attributes are checked according to the version of the GEXF
25 schemas used for parameters which are not user defined,
26 e.g. visualization 'viz' [2]_. See example for usage.
27
28 Parameters
29 ----------
30 G : graph
31 An EasyGraph graph
32 path : file or string
33 File or file name to write.
34 File names ending in .gz or .bz2 will be compressed.
35 encoding : string (optional, default: 'utf-8')
36 Encoding for text data.
37 prettyprint : bool (optional, default: True)
38 If True use line breaks and indenting in output XML.
39 version: string (optional, default: '1.2draft')
40 The version of GEXF to be used for nodes attributes checking
41
42 Examples
43 --------
44 >>> G = eg.path_graph(4)
45 >>> eg.write_gexf(G, "test.gexf")
46
47 """
48 writer = GEXFWriter(encoding=encoding, prettyprint=prettyprint, version=version)
49 writer.add_graph(G)
50 writer.write(path)
51
52
53def generate_gexf(G, encoding="utf-8", prettyprint=True, version="1.2draft"):

Callers

nothing calls this directly

Calls 3

add_graphMethod · 0.95
writeMethod · 0.95
GEXFWriterClass · 0.85

Tested by

no test coverage detected