Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subgraphs and contexts are conflated #19

Closed
james-d-mitchell opened this issue May 14, 2024 · 5 comments
Closed

Subgraphs and contexts are conflated #19

james-d-mitchell opened this issue May 14, 2024 · 5 comments

Comments

@james-d-mitchell
Copy link
Member

As far as I understand, the notions of subgraphs is one arising in graphviz/dot itself, and contexts are something that we are defining in this GAP package. As such it is a bit surprising that we can use GraphvizSubgraphs to retrieve contexts as in the following from subgraph.tst:

gap> g := GraphvizGraph();;
gap> GraphvizAddContext(g, ["a"]);;
gap> GraphvizSubgraphs(g)[["a"]];
<graphviz context [ "a" ] with 0 nodes and 0 edges>

(note that in my current version of graphviz I removed the function GraphvizGetSubgraph since it duplicates the functionality above).

@james-d-mitchell
Copy link
Member Author

Another example, in GraphvizAddContext there's the following code:

  subgraphs := GraphvizSubgraphs(graph);
  if IsBound(subgraphs[name]) then
    # TODO why are we talking about subgraphs in the error?
    ErrorFormatted("the 1st argument (a graphviz (di)graph) already has ",
                   " a subgraph with name \"{}\"", name);
  fi;

The error message is misleading since it refers to subgraphs, when we were trying to add a context, and the context is being added to GraphvizSubgraphs.

Maybe I misunderstood the difference between contexts and subgraphs, but if not, then it looks like we really need to have a GraphvizContexts function and underlying data structure.

@mpan322
Copy link
Contributor

mpan322 commented May 15, 2024

I agree this is a bit odd.
This behaviour exists as contexts where are essentially identical to subgraphs but with a different 'rendering' behaviour.
The error message is because at the moment subgraphs and contexts share a name space, once again due to the above.

Below is a draft of a rough specification new behaviour. Let me know if you have any concerns or thoughts:

  1. The parent of a subgraph will remain whatever the object it was added to (so in principle this could be a context).
  2. Subgraphs and contexts will no longer share a namespace.
  3. GraphvizSubgraphs will now only return subgraphs of the graph and a new GraphvizContexts will do the same for it's contexts.
  4. The subgraphs of a graph will be it's direct children (i.e. not children of it's contexts).

@james-d-mitchell
Copy link
Member Author

Thanks @mpan322, what you propose sounds good (if you mean by same namespace that they are stored in the same component of the object (i.e. Subgraphs or whatever it's called)).

@james-d-mitchell
Copy link
Member Author

If possible can you please make your changes on top of #21? This will make integrating it more straightforward

@james-d-mitchell
Copy link
Member Author

Fixed by #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants