ocamlgraph icon indicating copy to clipboard operation
ocamlgraph copied to clipboard

Add subgraph_hash in dot parser.

Open arbipher opened this issue 2 years ago • 3 comments

This PR adds a new entry function parse_all to get subgraph information when parsing a dot file.

In the old code, clust_nodes is defined, and used, but not returned. It's replaced by a graph_hash which records the nodes, attr, and parent using the parsing.

The previous parsing functions are only changed to drop not-use part of create_graph_and_clusters''s return values.

I make an issue #130 for more discussion.

arbipher avatar Nov 26 '22 03:11 arbipher

Many thanks for this PR and #130. I'll have a look at it and I'll merge the two of them if possible.

A quick question: have you checked that any .dot files in the repo (notably in editor/tests/ and dgraph/examples/) is still parsed successfully, in a backward compatible way?

backtracking avatar Nov 28 '22 12:11 backtracking

Not yet. I forgot there are dot files inside these two folders.

I can add a stanza in tests/dune to ensure all the dot files can parse successfully.

My PR currently is not so good, not only by (#130 Q2 Q3) but also my added structure for subgraph graph overlaps with the existing clust_attr. In design, graph contains the information of

  1. subgraph attr (recorded in clust_attr in old code, but not complete due to lack of handling Eq (id, id))
  2. subgraph nodes (recorded in clust_node in old code, but not returned)
  3. subgraph parenting relation (not recorded in the old code)
type graph = {
  sg_nodes : string list;
  sg_attr : attr list;
  sg_parent : string option;
}

I am also hoping I can remove clust_attr during the parsing but derive it in the end to satisfy the compatible function parse_bounding_box_and_clusters

arbipher avatar Nov 28 '22 16:11 arbipher

A quick question: have you checked that any .dot files in the repo (notably in editor/tests/ and dgraph/examples/) is still parsed successfully, in a backward compatible way?

It seems to take me nearly one year to answer this quick question 🎃.

I am working on a WIP PR to test parsing those dot files with the current dot parser and my modified parser, then check the equality of the results.

I added a dune alias dot_parse in tests/dune and tests/dot_parse.ml. Just dune build @runtest3

I copied the current src/dot.{ml,mli} to src/dot_v1.{ml,mli} and made my modified parser at src/dot.{ml,mli}. I have to add one line at module Dot_V1 = Dot_V1 to export Dot_V1. Then in test/dot_parse.ml, I compare the parsing results from both Dot and Dot_V1.

However, I don't figure out a good idea (ocamlgraph-way) to check the exactly equality of these two graphs in test/dot_parse.ml.

Now I just check they share the same number of vertices and edges. (The specific problem is G.mem_vertex g2 v1 always returns false)

I think some files just for testing during the PR discussion. When the issue is settled down, I can remove them.

arbipher avatar Nov 01 '23 01:11 arbipher