Code Monkey home page Code Monkey logo

graphsharp's Introduction

GraphSharp

nuget

LP solvers for GraphSharp

nuget

GraphSharp

GraphSharp is a tool to manipulate on the set of connected nodes, or just graph.

It is currently the most advanced graph library in c#.

Also, this library have adapters for graphs from another library QuikGraph.

And also for Satsuma

So any algorithms that works in these libraries also work here + this library contains lots and lots more algorithms and operations.

For samples see https://github.com/Kemsekov/GraphSharp.Samples

Various path finders example

Graph coloring (Greedy, DSatur, RLF, Coloring from QuikGraph) example

Delaunay triangulation example

Minimal spanning tree example

Topological sort example

Find articulation points example

Find components of a graph example

Cycles basis finder (here I color 10 shortest cycles found) example

Strongly connected components finder example

TravelingSalesmanProblem example

Hamiltonian cycle finder (using google or tools) output

Pagerank using QuikGraph example

Max flow algorithm using google or tools example

Min cost flow using google or tools example

Different graph center finders example

This example condenses cliques of original graph into nodes of new graph

Clique condensation graph condensedCliques

This example condenses strongly connected components of original graph into nodes of new graph

SCC condensation graph condensedSCC

graphsharp's People

Contributors

kemsekov 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

Watchers

 avatar  avatar  avatar  avatar  avatar

graphsharp's Issues

Create more samples

Create more simple samples and add README.md to each of them in order to explain what this library can do.

Move samples and benchmark to separate repositories

Holding all code of library, benchmark and samples in one repo is convenient for development, but it create a lot of noise in commits history (which btw is really a mess. Are you just too lazy to create good commits?).

Implement FindAllNodesPath

You have a sample that find the shortest path between two nodes, but have no example about finding the shortest path that visit all nodes. Do it pls.

Rename all Child to Edge.

Also maybe rename all variables in code from parent-child to something like parent-edge.

Let it be Children inside of INode, but the IChild and other components must be renamed to Edge.

Implement more test cases

Add wide rage of IVisitor.Select and IVisitor.EndVisit tests.
Maybe add separate tests for IPropagators.

Create more tests for separate components more than integrated tests, where all of them works together.

For example create custom empty Propagator and feed it to IGraph in order to test IGraph implementation more than IPropagator one.

Do the same for IPropagators.

Make NodesFactory-IGraph safer.

Currently your Graph accepts only nodes that going in the same order as their Id. In the same time each node must contain Children-edges that are from the same set of nodes. This is bad. It means users can add to Graph whatever they want as nodes, which can be invalid set of nodes. In the same time you have NodesFactory, that capable of creating right set of nodes and edges. Maybe you somehow link them?

Accept in Graph constructor NodesFactory instead of nodes itself. Make checks that this factory nodes count > 0 and make copy of it's nodes to current instance of Graph.

But in the NodesFactory you have a bunch of methods to set and manipulate nodes whatever the way you want. This can also lead to errors. For example you can set WorkingGroup to any set of nodes, not strictly the same set from currently working NodesFactory instance. Honestly, I have no Idea how to fix it, but maybe add a bit more warnings in the description of methods of NodesFactory?

`INode.Edges` cast in `INode{}` implementation is slow!

This part is really slow

        IEnumerable<IEdge> INode.Edges => this.Edges.Select(n=>n as IEdge);

It will do Select for each edge any time you will try to access Edges property. Because if this current version of library is 3x slower than previous one. Fix it

Make documentation cleaner

You are really bad at English, which is fine by itself, but my eyes bleed when I am trying to read your documentation. Pls do something about it.

I am taking about how Visitor works. It is not obvious from what you written in methods description. It is not obvious how selector affect next generation of nodes and what role Visit method has.

Also it is not obvious what IPropagator is and what it is doing.

You did little-to-none in order to explain what Graph.Step doing, and why it is even named step, if it using IPropagator? Maybe rename ot to Propagate?

Also add better description to README.md

Divide GraphStructure to functional classes

Your current impl of GraphStructure require a lot of lambda-configurations for it to work properly, meanwhile a lot of them may be not used in some cases of creating / altering nodes. This mean you break SRP in your GraphStructure instance. Fix it by dividing this big classes GraphStructure to separate more contained classes.

Refactor code and add features

1:

Refactor FindTheShortestPath sample. It just looks ugly. Update readme and docs in general. Remove example from readme and move it to samples. Add separate readme to each sample.

2:

Redesign NodeGraphFactory
Rename it to be just NodeFactory.
Create chain-like mechanism to creating nodes

NodeFactory
.Create() //create new list of nodes
.Use(nodes) //or use existing nodes
.Count(2000) //create 2000 nodes
.Connect(20) //connect each to exact 20
.ConnectRange(1,10) //connect randomly to some range of nodes
.ConnectToClosest((node1,node2)=>...integer...);
.MakeDirected()
.MakeUndirected();
//Etc...

Where ConnectToClosest is a type of connection you used in a find path samples. It just works so cool you MUST add it to default connection methonds.

Also pass to this methods all Funcs you need in order to create different types of nodes and children.

Use pipeline pattern to implement this.

3:

You current graph implementation of ParallelGraph and just Graph are bad. You using some other thing like IPropagator in order to 'hide' implementation that differs from graph to graph. Move this implementation out of the class itself. Do something with it so it will follow bridge design pattern, so singe Graph class will be able to became single threaded and parallel depend on this type.
Hinit - let users change IPropagator type to graph on their own, but let it by default be parallel, so it will make things a bit easier to maintain.

Also currently your IPropagators are doing almost the same thing in a very similar way. This breaks DRY principal. Do something about it.

4:

Add more tests for graph and other components of graph. Currently your tests are poor and do not cover all code behaviour properly.

5:

Implement second example - VisitAllNodes

6:

Currently for the sake of visualisation you using GraphDrawer which works fine but it is too much bound to imageSharp library. I mean you could in theory create some Avalonia.UI application that will use this class to draw graph on canvas dynamically.(which I hope you'll do, because WE NEED visualisation for GraphSharp). It's a shame that you so much lacks frontend skills.

Create graph visualisation in separate repository https://github.com/Kemsekov/GraphSharpGUI

  1. Update documentation to follow changes in api.

Design issue with `INode.Edges` and it's implementations

Problem

INode.Edges must be read-only. You cannot add or delete Edges from casted to down-level INode.
Currently your INode.Edges is IList which allows to add and remove nodes.

Solution

Create your own ImmutableCollection for list that also allows casting from inherited to base classes.

Rename `Propagator`s to BFS.

Your Propagator and ParallelPropagator is exactly doing BFS(«go wide, bird’s eye-view») from a graph theory. Rename it accordingly in order to avoid misunderstanding.

Add travelling salesman problem algorithm

move to the closest node each iteration. Do not visit the same node twice except for the first one(it will lock the cycle).
Every time you meet dead end(no avalliable path or someth) just go back to one

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.