Skip to content

Instantly share code, notes, and snippets.

@colllin
Last active February 12, 2024 18:36
Show Gist options
  • Save colllin/637f6d34a1e51512d7f27c702fb41e9a to your computer and use it in GitHub Desktop.
Save colllin/637f6d34a1e51512d7f27c702fb41e9a to your computer and use it in GitHub Desktop.
rustworkx issues / rough edges / room for improvement
  • serialization/deserialization symmetry

    • in general need more formatting options OR go to/from a major interchange format and recommend a separate library for every other kind of format in/out.
    • But need to support at least one text-based in/out so that we can easily print to inspect a graph
  • Why does rx.node_link_json require str values in the node and edge payloads, when JSON supports several other data types? This makes deserialization awkward and error-prone, so for now I'm just converting the nodes to {'json': json.dumps(node_payload)}.

  • no node_index_map()? So you have this clunky interface where you can get either the indices or the data but not both

  • subgraph() resets node indices 😱🤯

  • add_nodes_from() should just be called add_nodes(), same for add_edges_from()

  • compose() accepts an edge map which prevents having multiple edges from one node in the main graph to multiple nodes in the added fragment. Instead, it should accept an edge list in the same format used by add_edges_from()

  • rx.union() should accept a merge predicate function to determine which nodes to merge, and/or the attrs of the merged node

  • PyGraph.contract_nodes() equivalent to merge_nodes() in DiGraph and DAG? (Should be same name...)

  • rx.is_subgraph_isomorphic(graph1, graph2) returns True when graph1 is empty (has 0 nodes) and graph2 is not empty (has >0 nodes), but I believe it should return False, since an empty graph shouldn't have any subgraphs that are isomorphic with graph2... right?

    • workaround? instead of rx.is_subgraph_isomorphic, use next(rx.vf2_mapping(..., subgraph=True), None) is not None

      def is_subgraph_isomorphic(*args, **kwargs):
          return next(vf2_mapping(*args, subgraph=True, **kwargs), None) is not None
      
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment