Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drathier/elm-graph
Simple graph library in Elm.
https://github.com/drathier/elm-graph
Last synced: about 1 month ago
JSON representation
Simple graph library in Elm.
- Host: GitHub
- URL: https://github.com/drathier/elm-graph
- Owner: drathier
- License: bsd-3-clause
- Created: 2017-03-10T22:34:42.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-13T21:29:08.000Z (about 6 years ago)
- Last Synced: 2024-05-21T12:33:34.321Z (7 months ago)
- Language: Elm
- Size: 92.8 KB
- Stars: 2
- Watchers: 6
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-graph [![Build Status](https://travis-ci.com/drathier/elm-graph.svg?token=z813a3NqyNRAhrQwc49e&branch=master)](https://travis-ci.com/drathier/elm-graph)
Elm-graph is a simple library for mathematical graphs (nodes and edges).Keys used to identify nodes can be any `comparable`, and both nodes and edges can have any kind of metadata associated with them.
All operations that look at a single node are at most `O(log n)`. Operations that look at all elements in the graph are at most `O(n log n)`.
InsertEdge functions insert missing nodes as needed.
`Data` suffix insert functions overwrite metadata. Insert functions without `Data` suffix clear metadata.```
example =
let
graph =
empty
|> insertEdge 5 1 -- automatically creates missing nodes
|> insertEdge 1 2
|> insertEdge 3 2
|> insertEdge 5 2
|> insertEdge 1 3
|> insertEdge 2 3
|> insertEdge 2 4
|> insertEdge 3 5
|> insertEdge 4 5
|> insert 42 -- explicitly create node without edges or metadata
|> insertData 42 "node metadata" -- overwrite node, replacing metadata (if there is any)
|> insertEdgeData 42 55 ("metadata", "for", "edge")
in
incoming 2 graph -- [ 1, 3, 5 ]
```