Code Monkey home page Code Monkey logo

goraph's Introduction

goraph Go Report Card Build Status Godoc

Package goraph implements graph data structure and algorithms.

go get -v gopkg.in/gyuho/goraph.v2;

I have tutorials and visualizations of graph, tree algorithms:
For fast query and retrieval, please check out Cayley.

goraph's People

Contributors

forwooditsworth avatar gyuho avatar samschaevitz avatar tcharding 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  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  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

goraph's Issues

Silently ignore Undeclared Edge

Hi, and thank you for this package.

I notice a slight problem when adding edge before declaring both vertex: the edge is not added silently.
I think it should either complain or directly add a new vertex.

func Works() {
    workingGraph := graph.NewDefaultGraph()
    workingGraph.AddVertex("A")
    workingGraph.AddVertex("B")
    workingGraph.AddEdge("A", "B", 1)
    fmt.Printf("Graph is printing: %v", workingGraph)
    order, _ := graph.TopologicalSort(workingGraph)
    fmt.Printf("Order is right: %v\n\n", order)
}

func Fails() {
    workingGraph := graph.NewDefaultGraph()
    workingGraph.AddVertex("A")
    workingGraph.AddEdge("A", "B", 1) // Silently accept Edge on non-existent
    workingGraph.AddVertex("B")
    fmt.Printf("Graph is not printing: %v\n", workingGraph)
    order, _ := graph.TopologicalSort(workingGraph)
    fmt.Printf("Order is wrong: %v\n", order)
}

Error building shortest_path.go

Hi,

When I try to build shortest_path.go, I get the following error messages:

.\shortest_path.go:54: undefined: nodeDistanceHeap
.\shortest_path.go:72: undefined: nodeDistance
.\shortest_path.go:86: undefined: nodeDistance

I couldn't find any reference to nodeDistanceHeap or nodeDistance in the project. Am I missing something?

Do you need HeiankyoView?

Hi, I started Go and I was searching for a graph library in Go, and found this project. Looks good to me.

I think you plan to implement a module to import/export from/to dot language from and it's really a good idea. But, how about other visualization technique such as treemap?

HeiankyoView, I have implemented, is another method of visualizing tree structure and now implemented in Python. https://github.com/akiradeveloper/HeiankyoView
I have a plan to rewrite this in Go and probably the best way is to construct it on top of standard graph library, which I suppose this is.

If I implement HeiankyoView on top of goraph. Will you merge? (drill down viz/heiankyoview)

or do you introduce me better graph library?

Tarjan with very large graph generate "goroutine stack exceeds 1000000000-byte limit"

Situation:
I have a graph with close to 2 Millions nodes and many more edges

Problem:
call to Tarjan provokes a stack limit error

Note:
goraph is great piece of SW and this is a minor issue. A work around was found.

row  1726 4030 MiBGraph nb of nodes                1992378
runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow

runtime stack:
runtime.throw(0x551515, 0xe)
        C:/Go/src/runtime/panic.go:608 +0x79
runtime.newstack()
        C:/Go/src/runtime/stack.go:1008 +0x737
runtime.morestack()
        C:/Go/src/runtime/asm_amd64.s:429 +0x97

goroutine 1 [running]:
runtime.interhash(0xc0f0001450, 0xe8426d0d, 0x42a209)
        C:/Go/src/runtime/alg.go:140 +0x182 fp=0xc0f0001368 sp=0xc0f0001360 pc=0x402f92
runtime.mapaccess2(0x524820, 0xc0271566f0, 0xc0f0001450, 0x3011f, 0x0)
        C:/Go/src/runtime/map.go:456 +0x78 fp=0xc0f00013b0 sp=0xc0f0001368 pc=0x40d038
github.com/gyuho/goraph.(*graph).unsafeExistID(...)
        C:/Users/Tensor/go/src/github.com/gyuho/goraph/graph.go:220
github.com/gyuho/goraph.(*graph).GetTargets(0xc027156780, 0x571f00, 0xc01d2b91a0, 0x0, 0x0, 0x0)
        C:/Users/Tensor/go/src/github.com/gyuho/goraph/graph.go:389 +0xde fp=0xc0f00014d0 sp=0xc0f00013b0 pc=0x4fc4ae
github.com/gyuho/goraph.tarjan(0x573200, 0xc027156780, 0x571f00, 0xc01d2b91a0, 0xc00009c0c0)
        C:/Users/Tensor/go/src/github.com/gyuho/goraph/strongly_connected_components.go:138 +0x1fe fp=0xc0f00016d0 sp=0xc0f00014d0 pc=0x4fd00e
github.com/gyuho/goraph.tarjan(0x573200, 0xc027156780, 0x571f00, 0xc01d2b9220, 0xc00009c0c0)
        C:/Users/Tensor/go/src/github.com/gyuho/goraph/strongly_connected_components.go:148 +0x4a3 fp=0xc0f00018d0 sp=0xc0f00016d0 pc=0x4fd2b3
github.com/gyuho/goraph.tarjan(0x573200, 0xc027156780, 0x571f00, 0xc01d2b92e0, 0xc00009c0c0)
        C:/Users/Tensor/go/src/github.com/gyuho/goraph/strongly_connected_components.go:148 +0x4a3 fp=0xc0f0001ad0 sp=0xc0f00018d0 pc=0x4fd2b3
github.com/gyuho/goraph.tarjan(0x573200, 0xc027156780, 0x571f00, 0xc04810c6e0, 0xc00009c0c0)

export graph to image

Hello,

great library. Is there a way to export the graph to svg or are there plans?

edit: i guess that should be done with graphviz?

Thanks,
Gerald

Export an Error to signify missing nodes

goraph uses errors.New() to create errors to signal missing graph nodes in numerous places. e.g.

return fmt.Errorf("%s does not exist in the graph.", id1)

It would be better to create specific error type instead. This would reduce code duplication and would allow callers to distinguish missing nodes from other things that may have go wrong when using the library.

Order of topological sort varies between executions

Whilst it seems to maintain the correct ordering, the Topological sort seems to vary slightly the order of results in between executions. Perhaps there is a map in there some where giving it random order?

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.