Write G in GraphML XML format to path Parameters ---------- G : graph A easygraph graph path : file or string File or filename to write. Filenames ending in .gz or .bz2 will be compressed. encoding : string (optional) Encoding for text data. prett
(
G,
path,
encoding="utf-8",
prettyprint=True,
infer_numeric_types=False,
named_key_ids=False,
edge_id_from_attribute=None,
)
| 65 | |
| 66 | @open_file(1, mode="wb") |
| 67 | def write_graphml_xml( |
| 68 | G, |
| 69 | path, |
| 70 | encoding="utf-8", |
| 71 | prettyprint=True, |
| 72 | infer_numeric_types=False, |
| 73 | named_key_ids=False, |
| 74 | edge_id_from_attribute=None, |
| 75 | ): |
| 76 | """Write G in GraphML XML format to path |
| 77 | |
| 78 | Parameters |
| 79 | ---------- |
| 80 | G : graph |
| 81 | A easygraph graph |
| 82 | path : file or string |
| 83 | File or filename to write. |
| 84 | Filenames ending in .gz or .bz2 will be compressed. |
| 85 | encoding : string (optional) |
| 86 | Encoding for text data. |
| 87 | prettyprint : bool (optional) |
| 88 | If True use line breaks and indenting in output XML. |
| 89 | infer_numeric_types : boolean |
| 90 | Determine if numeric types should be generalized. |
| 91 | For example, if edges have both int and float 'weight' attributes, |
| 92 | we infer in GraphML that both are floats. |
| 93 | named_key_ids : bool (optional) |
| 94 | If True use attr.name as value for key elements' id attribute. |
| 95 | edge_id_from_attribute : dict key (optional) |
| 96 | If provided, the graphml edge id is set by looking up the corresponding |
| 97 | edge data attribute keyed by this parameter. If `None` or the key does not exist in edge data, |
| 98 | the edge id is set by the edge key if `G` is a MultiGraph, else the edge id is left unset. |
| 99 | |
| 100 | Examples |
| 101 | -------- |
| 102 | >>> G = eg.path_graph(4) |
| 103 | >>> eg.write_graphml(G, "test.graphml") |
| 104 | |
| 105 | Notes |
| 106 | ----- |
| 107 | This implementation does not support mixed graphs (directed |
| 108 | and unidirected edges together) hyperedges, nested graphs, or ports. |
| 109 | """ |
| 110 | writer = GraphMLWriter( |
| 111 | encoding=encoding, |
| 112 | prettyprint=prettyprint, |
| 113 | infer_numeric_types=infer_numeric_types, |
| 114 | named_key_ids=named_key_ids, |
| 115 | edge_id_from_attribute=edge_id_from_attribute, |
| 116 | ) |
| 117 | writer.add_graph_element(G) |
| 118 | writer.dump(path) |
| 119 | |
| 120 | |
| 121 | @open_file(1, mode="wb") |
no test coverage detected