Package: xnetwork
XNET File format (xnetwork)xnetworkis a small python package that allows you to read.xnetfiles (compleX NETwork format), a format designed to easily handle graph data with multiple attributes.This file format is used across several of my other projects, includingHelios-Web.InstallationYou can easily installxnetworkby usingpip:pipinstallxnetworkUsageLoading a GraphTo read a Graph from a.xnetformatted file, simply use theloadfunction:fromxnetworkimportloadgraph=load("path_to_file.xnet")Saving a GraphTo save a graph object to.xnetformat:fromxnetworkimportsavefromigraphimportGraph# Your igraph graph objectg=Graph()save(g,"output_file.xnet").xnet FormatA brief overview of the.xnetformat:#vertices <number_of_vertices>
<Vertex 0 name>
<Vertex 1 name>
...

#edges weighted|nonweighted undirected|directed
<source_vertex> <target_vertex> [weight]
...

#v "<vertex_attribute_name>" s|n|v2|v3
<attribute_value>
...

#e "<edge_attribute_name>" s|n|v2|v3
<attribute_value>
...The#verticestag specifies the number of vertices in the graph, followed by their labels.The#edgestag specifies if edges are weighted or non-weighted and whether they are directed or undirected. Each subsequent line lists an edge by its source and target vertices, optionally followed by a weight in square brackets.The#vand#etags specify vertex and edge attributes respectively. These tags are followed by the attribute name and its type. The type can be a string (s), number (n), 2D vector (v2), or 3D vector (v3).ExampleConsider the following.xnetfile:#vertices 4 
"Label 0"
"Label 1"
...
#edges weighted undirected
0 1 [0.1]
0 2 [0.2]
...
#v "A string property" s
"A string value"
"Another string value"
...This represents a graph with 4 vertices and 2 weighted, undirected edges.API Referenceload(fileName='test.xnet', compressed=False)Read a Graph from a xnet formatted file.ParametersfileName: string
Input file path.compressed: bool
If True, input file is compressed using gzip.Returnsigraph.Graph: The graph object loaded from the file.save(g, fileName='test.xnet', ignoredNodeAtts=[], ignoredEdgeAtts=[], compressed=False)Write igraph object to .xnet format.Vertex attributes 'name' and 'weight' are treated in a special manner. They correspond to attributes assigned inside the #vertices tag. Edge attribute 'weight' is assigned to edges inside the #edges tag.Parametersg: igraph.Graph
Input graph.fileName: string
Output file.ignoredNodeAtts: list
List of node attributes to ignore when writing graph.ignoredEdgeAtts: list
List of edge attributes to ignore when writing graph.compressed: bool
If True, output file will be compressed using gzip.ReturnsNone: The function saves the graph object to the specified file.Special network attribute namesSome attribute names are interpreted by certain software in different ways.Node attribute namedLabelis interpreted as vertex label.Node attribute namedPositionis interpreted as vertex position (can be v2 or v3).Node attribute namedweightis interpreted as edge weight.AuthorsFilipi N. Silva (filipinascimento.github.io)Cesar H. CominLicenseThis project is licensed under the MIT License.LinksGitHub RepositoryFeel free to contribute and raise issues on the GitHub repository.