Changelog

1.1.3

  • Minor bug fix for edge ID generation.

1.1.2

  • Added DeprecationWarning on import. Package will be replaced by ragraph.

1.1.1

  • Bug fix for graph_io.generic.utils.select_nodes when only a single node kind is selected.

1.1.0

1.0.1

  • Fix loading of JSON dictionaries with an empty edge dict.

1.0.0

  • Added unique edge ID numbering in a graph_io.Graph, which is available in its new properties.

    • The graph_io.Edge class remains untouched. This means that the IDs are not stored inside the edges itself.

    • The JSON format has been changed slightly, where the unique numbering is now used to uniquely identify edges instead of a long array.

  • Unified the JSON and YAML import and export functionality. Where the YAML module used to support exporting any of the main classes, this is now restricted to the graph_io.Graph object only. This is more in line with the other modules.

0.7.0

  • Added a graph_io.Graph.get_node_selection interface.

    • Especially useful when grabbing nodes for display purposes. When displaying multiple node kind domains, the first kind can be set as “leading”, which will only show nodes from other domains that share at least one edge with the leading kind’s nodes at a certain maximum depth.

0.6.1

  • Added resolving of GoalMigrationReason.

0.6.0

  • Added an indexing interface to the graph_io.Graph class.

    • When indexing with a single node name, you get the node from the graph’s node dictionary. E.g. graph["node_name"] == graph.node_dict["node_name"].

    • When indexing with a source and target tuple, you get the edges between those. E.g. graph["source", "target"] == graph.edge_dict["source"]["target].

    • These also work for the following checks: "node_name" in graph returns True if that node name exists in the graph and ("source", "target") in graph returns True if there are any edges in the graph from source to target.

0.5.2

  • Improved automatic handling of setting/changing the parent or children of nodes.

0.5.1

  • EslUsageReason resolving has been added for the missing dependencies that have been added to the output of the ESL compiler.

0.5.0

0.4.0

  • Node class now sports a graph_io.Node.width property that returns the width of the branch starting at that node (e.g. the number of leaf nodes in that branch).

0.3.0

  • Added support for matrix import and export from graphs! Long overdue, but now you can convert a Numpy 2D-array or list-of-lists to a graph. Also, converting to a matrix has been moved to this module such that we now have a single method to create adjacency or mapping matrices. See the graph_io.matrix reference for more information.

>>> from graph_io import matrix
>>> import numpy as np
>>> lol = [[0,1],[2,3]]
>>> graph = matrix.from_matrix(lol)
>>> print((len(graph.nodes), len(graph.edges))
(2, 3)  # The cell at [0,0] with weight 0 is ignored! (this can be customized)
>>> arr = np.array(lol)
>>> graph2 = matrix.from_matrix(arr)
>>> graph2 == graph
True

>>> matrix.to_matrix(graph)
array([[0., 1.],
       [2., 0.]])
  • Added graph_io.Graph.get_mapping_matrix to support mapping matrices instead of square adjacency matrices only – directly from the graph instance. Note that a mapping matrix is directed! (columns are inputs to rows)

>>> graph.get_mapping_matrix(["node0"], ["node1"])
array([[1.]])

0.2.0

  • Added a method to obtain an adjacency matrix to the graph_io.Graph class. It has arguments to select specific nodes, enable calculation of self-loops (0.0 otherwise) and edge weight inheritance of their children. Usage:

>>> from graph_io import Graph, Node, Edge
>>> a = Node("a")
>>> b = Node("b")
>>> a1 = Node("a.1", parent=a)
>>> b1 = Node("b.1", parent=b)
>>> g = Graph(nodes=[a, b, a1, b1], edges=[Edge(a, a), Edge(a, b), Edge(a1, a1), Edge(b1, a1)])
>>> g.get_adjacency_matrix(nodes=[a,b], inherit=False, loops=False)
array([[0., 0.],
       [1., 0.]])
>>> g.get_adjacency_matrix(nodes=[a,b], inherit=True, loops=False)
array([[0., 1.],
       [1., 0.]]
>>> g.get_adjacency_matrix(nodes=[a,b], inherit=False, loops=True)
array([[1., 0.],
       [1., 0.]])
>>> g.get_adjacency_matrix(nodes=[a,b], inherit=True, loops=True)
array([[2., 1.],
       [1., 0.]])
  • Changed the edge dictionary to be a defaultdict, so now this will always pass and return an empty list if the node (names) don’t exist in the graph:

>>> g.edge_dict["sourcenode"]["targetnode"]
[]

0.1.1

Cleanup YAML importer/exporter. Usage not changed.

0.1.0

Added equality checking of graph_io.Graph objects via their JSON dict representations.

0.0.2

Fixed up recursion consistency check in Graph.check_consistency().

0.0.1

Initial version from template.