GithubHelp home page GithubHelp logo

graph's People

Contributors

koenichiwa avatar

Stargazers

 avatar

Watchers

 avatar

graph's Issues

Fix addEdge/updateEdgeValue/getEdgeValue of MutableValuedAdjacencyMatrixGraphImpl

The tests updateEdgeValue works and getEdgeValue works. This might also be an issue with addEdge. It seems that even in an undirected graph the value is added to only one direction. This creates an error when the value is polled for the other direction, because it's not expected to be null when in the _adjacencyMatrix it clearly says that there is a value in that direction.

This can be an issue in the instantiation of the edge. Maybe in the _edgeValueMap the pair is not switched around, e.g. _edgeValueMap[from to to] = value is ran twice, and _edgeValueMap[to to from] = value is not run.

Write tests for AdjacencyMatrix implementations

Although adjacency matrix is merged, it's tests aren't written. This should happen in a separate package in the test directory, same as with adjacencymap. The tests can mostly be copied from adjacencymap as well. Be sure to add an @test annotation to every function to ensure it's ran at the build.

Fix addVertex function of AdjacencyMatrix

The AdjacencyMatrix addVertex function doesn't seem to be working.

After adding 3 vertices to a newly instantiated MutableAdjacencyMatrixGraphImpl object the _adjacencyMatrix value holds three mutableLists (which is expected) but they all have different sizes (which is not expected, the should all hold three false boolean values). The first list is of size 2, the second of size 1 and the third of size 0. I expect that in the addVertex function it is not checked how many other vertices are currently in the graph. It should also be instantiated with a size of at least 1, as a vertex can also have an edge to itself.

Be when adding a vertex a new MutableList is instantiated, and is populated with false boolean values the size of _vertexList.

Implement incidence matrix

Currently only the adjacency matrix and the adjacency list (renamed to adjacency map) are implemented. For sake of completeness the incidence matrix should also be implemented.

The incidence matrix is an undirected graph and should be implemented in that way. Consider what this means for the implementation of the other graphs. Currently those are implemented such that the user can choose wether they're directed or undirected at instantiation.

Storage should be a two-dimensional matrix, in which the rows represent the vertices and columns represent the edges. It should either store a Boolean in case of the unvalued graph, or a nullable value in case of the valued graph. Also consider using a separate data-structure for storing the values, because it might cause issues if the value type is inherently nullable. The entries in the matrix indicate whether the vertex at a row is incident to the edge at a column, false or null indicates no incidence.

Adding and removing a vertex or an edge should take O(V * E) time, testing incidence should take O(E). Here V and E indicate the amount of vertices and edges respectively.

All classes and abstract classes used for this issue should be created in a separate package named incidencematrix. Also a puml file should be created in the docs describing the class structure

For more information on how to implement see the page on wikipedia

Instantiate one graph from another

It would be nice to be able to create a graph with another graph. This way a AdjacencyMapGraph can be copied to an AdjacencyMatrixGraph and vice versa. This means that MutableAdjacencyMatrixGraphImpl(graphOf(true, 1 to setOf())) should be valid code. Also be sure to add this functionality to the Instantiation file. graphOf(graphOf(true, 1 to setOf()) should thus be valid, also think about creating an directed graph from an undirected graph, and if implementing an undirected graph from an directed graph can be possible. adapting directed to undirected means that half the information is lost, so for the implementation there needs to be a valid consensus on which information is retained.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.