Coder Social home page Coder Social logo

datastructures.algorithms's People

Contributors

herbertwraneschitz avatar mfe- avatar stephentoub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

datastructures.algorithms's Issues

Directed graph with custom Vertex widthxheight shifts arrow wrong

When setting a custom width and height >40 on the VertexControl on a directed graph the arrow is underneath the control. Therefore it looks like that the arrow isn't displayed. The ShiftConverter is currently using hardcoded +-7.

To fix this:

  • Pass additonal parameter with width and height of control to ShiftConverter
  • Calculate a reasonable value which can be used to shift the arrow

Make use of Guid for Vertex comparision

  • Define or extend interface of IVertex which makes it possible to use the internal Guid for comparision of vertex1 and vertex2; Possible candidate IComparable<Guid> or IEquatable<IntPtr>
  • Adjust algo.

IVertex parameter is null in OnBreadthFirstSearchCommand(IVertex vertex) method and Kruskal doesn't work

Repro steps:

  1. Clone the code from main branch and open with VS2022.

  2. Press F5 to launch the DataStructures.UI.Demo project.

  3. Select node 3 and right-click to choose BreadthFirstSearch option.
    image

  4. It will throw Object reference not set to an instance of an object at DataStructures.UI.Demo\Window1ViewModel.cs:line 116

Findings:
After checking the line 116, we found the vertex object is null.

Another issue:

  1. Press F5 to launch the DataStructures.UI.Demo project.
  2. Select node 3 and right-click to choose Kruskal option.

Excepted Result:
The screen should show this result.
image

Actual Result:
The screen doesn't do any changes. It keeps in this:
image

Detect opposite edge in an easy way

vertices in a undirected graph will be connected by two edges.
E.g (where "->" and "<-" is representing an edge):
v1 -> v2
v1 <- v1

This fact requires to implement additonal checks in DFS and other graph algorithm.
E.g.:

    private static IEnumerable<IEdge> DepthFirstSearch(IVertex current, List<IEdge> edges, IVertex goal)
    {
        //mark edges
        foreach (IEdge e in current.Edges)
        {
            //check if we found the goal
            if (e.V.Equals(goal))
            {
                //some special behaviour duo circlues which we have to consider resulting of the our model (undirected: 1->3, 3->1)
                if (!edges.First().U.Edges.SelectMany(a => a.V.Edges).ToList().Exists(y => y.Equals(e))//schauen ob er zurückgehen will
                    || (edges.First().U.Edges.SelectMany(a => a.V.Edges).ToList().Exists(y => y.Equals(e) && //(kreis existiert mit IEdge ausgehend vom start), (schauen ob dazwischen noch andere IEdges sind)
                    edges.Find(delegate (IEdge ed) { return ed.V == e.U && ed.U != e.V; }) != null)))
                {
                    edges.Add(e);
                    return edges;
                }
           [...]

Therefore we should provide a method which considers the opposite edge when checking if the edge was already visitied.

lazy iterable vertex/ edge list

Keeping the whole vertex /edge list in memory allocates too much space in some scenarios.
When iterating over vertices /edge list, it should be possible to outsource them (for example into a file by using the existing deserializing function or simply save the guid of the vertex or edge).

  • Implement outsourcing part of the vertice/edge list by saving them into a file.

Remove INPC from IVertex(Vertex)

image

Remove INPC from IVertex(Vertex).
Because the UI GraphControl requires INPC we can create an own Vertex class which implements INPC

Too many collisions with <250000 edges when comparing with Edge.GetHashCode for transposed

When generating more than 250000 edges with Generate_Grid_Graph there are many collisions using Edge.GetHashCode

return Math.Abs(U.GetHashCode()) + (V != null ? Math.Abs(V.GetHashCode()) : 0);

U.GetHashCode() =       return this._Guid.Equals((obj as Vertex)?._Guid);

Currently workaround.

return ($"{U}{V}" == $"{edge.U}{edge.V}" || $"{U}{V}" == $"{edge.V}{edge.U}");

Maybe the Guid of the Vertex should be exposed in IVertex so it can be used for comparison in the implementation of Edge.
The Edge itself could generate a new Guid of Vertex.U and Vertex.V.

https://gist.github.com/mfe-/c23279f73f1b2373eeeb4a8baa5d7906

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.