feat(adjacency) hasVertex for Graphs #400
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
predecessor: #398
I thought a bit about addVertex:
for Adjacency Matrix, it seems it doesn't fit the adjacency matrix model since it contradicts its definition; IF we are to store vertices info in it, it'll become not just BitField but BitMatrix (since we need n^2 booleans to keep the number of edges); which effectively becomes BitMatrix
for BitMatrix, I haven't added addVertex yet and haven't considered it diligently yet, since it doesn't fit the initial idea of "Grapg Interface" anymore (no "addVertex" because of the AdjacencyList consideration above)
Note that BitField doesn't seem to be enough to track Vertices because it loses the info about "how many are there"
Therefore I'm isolating this PR to hasVertex only:
still, there is no BitMatrix (or BitField) used for AdjacencyList because of the considerations above (it seems it becomes AdjacencyBitMatrix, effectively, and we already have that), therefore edge presence implemented through
degree
for AdjacencyBitMatrix, BitMatrix is already there, however O(n) scans needed to determine the presence of a bit to know a vertice is present
nothing new for AdjacencyList
Added some tests, including a bit unrelated bitFIeld test (it is a side effect of me figuring it out 😆 )