Generate lines of GEXF format representation of G. "GEXF (Graph Exchange XML Format) is a language for describing complex networks structures, their associated data and dynamics" [1]_. Parameters ---------- G : graph A EasyGraph graph encoding : string (optional, defaul
(G, encoding="utf-8", prettyprint=True, version="1.2draft")
| 51 | |
| 52 | |
| 53 | def generate_gexf(G, encoding="utf-8", prettyprint=True, version="1.2draft"): |
| 54 | """Generate lines of GEXF format representation of G. |
| 55 | |
| 56 | "GEXF (Graph Exchange XML Format) is a language for describing |
| 57 | complex networks structures, their associated data and dynamics" [1]_. |
| 58 | |
| 59 | Parameters |
| 60 | ---------- |
| 61 | G : graph |
| 62 | A EasyGraph graph |
| 63 | encoding : string (optional, default: 'utf-8') |
| 64 | Encoding for text data. |
| 65 | prettyprint : bool (optional, default: True) |
| 66 | If True use line breaks and indenting in output XML. |
| 67 | version : string (default: 1.2draft) |
| 68 | Version of GEFX File Format (see http://gexf.net/schema.html) |
| 69 | Supported values: "1.1draft", "1.2draft" |
| 70 | |
| 71 | |
| 72 | Examples |
| 73 | -------- |
| 74 | >>> G = eg.path_graph(4) |
| 75 | >>> linefeed = chr(10) # linefeed=\n |
| 76 | >>> s = linefeed.join(eg.generate_gexf(G)) |
| 77 | >>> for line in eg.generate_gexf(G): # doctest: +SKIP |
| 78 | ... print(line) |
| 79 | |
| 80 | Notes |
| 81 | ----- |
| 82 | This implementation does not support mixed graphs (directed and undirected |
| 83 | edges together). |
| 84 | |
| 85 | The node id attribute is set to be the string of the node label. |
| 86 | If you want to specify an id use set it as node data, e.g. |
| 87 | node['a']['id']=1 to set the id of node 'a' to 1. |
| 88 | |
| 89 | References |
| 90 | ---------- |
| 91 | .. [1] GEXF File Format, https://gephi.org/gexf/format/ |
| 92 | """ |
| 93 | writer = GEXFWriter(encoding=encoding, prettyprint=prettyprint, version=version) |
| 94 | writer.add_graph(G) |
| 95 | yield from str(writer).splitlines() |
| 96 | |
| 97 | |
| 98 | @open_file(0, mode="rb") |
nothing calls this directly
no test coverage detected