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

Modified isSubGraph in Labelled.AdjacencyMap, minor error rectified #221

Closed
wants to merge 8 commits into from

Conversation

adithyaov
Copy link
Contributor

Changed Labelled.AdjacencyMap.isSubGraph

Please note that I am unable to run the tests (QuickCheck) on my system due to a problem with WSL. So the only option for me to verify if the tests are passing is Travis CI.

@snowleopard
Copy link
Owner

@adithyaov The following properties should be satisfied by isSubgraphOf:

isSubgraphOf x (overlay   x y) == True
isSubgraphOf x (connect e x y) == True
isSubgraphOf y (connect e x y) == True

I don't think your current implementation satisfies these requirements.

@snowleopard
Copy link
Owner

Also, if you are fixing a bug, please add a test that currently fails but passes with yours fix.

@adithyaov
Copy link
Contributor Author

adithyaov commented Jul 19, 2019

@snowleopard

isSubgraphOf x (overlay   x y) == True
isSubgraphOf x (connect e x y) == True
isSubgraphOf y (connect e x y) == True

Satisfying the properties above becomes really complex. Please note the following, say,

x = edge (Sum 2) 0 1
y = edge (Sum -2) 0 1
z = overlay x y = vertices [0, 1]

Justifying that x is a subgraph of z is quite dufficult. We would probably need to check different conditions depending on the Monoid (edge).
In case of Sum, isSubgraphOf x y = isSubMapOfBy (isSubMapOfBy (\_ _ -> True)) x y as Sum can result in anything.
I'll get back to this PR after some amount of thought.

@snowleopard
Copy link
Owner

snowleopard commented Jul 19, 2019

@adithyaov We typically want edge labels to come from a dioid:

http://hackage.haskell.org/package/algebraic-graphs-0.4/docs/Algebra-Graph-Label.html#t:Dioid

Sum is not a dioid, which is why you have issues here. Combining algebraic graphs and non-dioids is problematic, because many basic properties no longer hold, e.g. x + x = x.

Both Distance and Capacity are dioids, so there should be no issues with them.

Dioids are idempotent, which allows us to keep the monotonicity of algebraic graphs: by overlaying a graph with another graph, we can only add structure, not remove it.

@adithyaov
Copy link
Contributor Author

adithyaov commented Jul 19, 2019

@snowleopard
Ah, I see, In that case, I believe the previous implementation is correct. I think one should probably change isSubgraphOf to work only with dioids.
I think I got an error as I was checking it for the monoid Sum.

@snowleopard
Copy link
Owner

I think I got an error as I was checking it for a Sum Monoid.

Right, I see. Indeed, with Sum there will be a few issues. I added a note about this: #175 (comment).

If the current implementation works for dioids, then I think there is no need to change anything for now, but we'll definitely need to improve documentation for edge-lebelled graphs, as discussed in #175.

@adithyaov
Copy link
Contributor Author

adithyaov commented Jul 20, 2019

Closing this PR for now. Please feel free to reopen this if required.
Please refer to #175

@adithyaov adithyaov closed this Jul 20, 2019
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

Successfully merging this pull request may close these issues.

2 participants