Code Monkey home page Code Monkey logo

simplevaluegraphs.jl's Introduction

SimpleValueGraphs.jl

version Stable Dev CI codecov

SimpleValueGraphs is a Graphs.jl compatible package for graphs with multiple, homogeneous vertex, edge and graph metadata. In particular it provides:

  • an abstract interface for graphs with metadata
  • concrete implementations of mutable graphs with metadata

Compared to SimpleWeightedGraphs.jl it has the following advantages:

  • vertex and graph metadata
  • multiple edge metadata
  • faster structural modifications of graphs

Compared to MetaGraphs.jl it has the following advantages:

  • faster access and modifications of metadata
  • better type stability when accessing metadata

Example

using SimpleValueGraphs

using Graphs: smallgraph
using Plots
using GraphRecipes: graphplot
using Colors: RGB, Color

# Load a Graphs.SimpleGraph
gs = smallgraph(:house)

# Convert to a ValGraph with vertex and edge values
gv = ValGraph(gs;
    # Two names vertex values:
    # - color: A random color
    # - label: The vertex identifier as a string
    vertexval_types=(color=Color, label=String),
    vertexval_init=v -> (rand(RGB), string(v)),
    # One unnamed edge value:
    # A string s -- d from source to destination of each edge
    edgeval_types=(String, ),
    edgeval_init=(s, d) -> ("$s -- $d",)
)

# Plot this graph using the vertex and edge values
graphplot(gv;
    nodecolor = [get_vertexval(gv, v, :color) for v in vertices(gv)],
    names = [get_vertexval(gv, v, :label) for v in vertices(gv)],
    edgelabel=weights(gv; zerovalue="")
)

example output

Benchmarks

This is a comparison of running Graphs.dijkstra_shortest_paths on the egonets-Facebook graph for multiple graph types.

graph type time (ms)
Graphs.SimpleGraph + Matrix weights 6.5
Graphs.SimpleGraph + SparseMatrixCSC weights 11.4
SimpleWeightedGraphs.SimpleWeightedGraph 11.7
MetaGraphs.MetaGraph 141.9
SimpleValueGraphs.ValGraph 12.4

Currently a lot of Graphs.jl algorithms do not optimally work with graphs that store edge metadata internally. The next benchmark is an optimized version of the same algorithm that can be found in SimpleValueGraphs.Experimental.dijkstra_shortests_pasts. Clearly, this is a huge improvement for ValGraph and SimpleWeightedGraph.

graph type time (ms)
Graphs.SimpleGraph + Matrix weights 6.8
Graphs.SimpleGraph + SparseMatrixCSC weights 10.8
SimpleWeightedGraphs.SimpleWeightedGraph 2.9
MetaGraphs.MetaGraph 147.3
SimpleValueGraphs.ValGraph 3.1

simplevaluegraphs.jl's People

Contributors

simonschoelly avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

pitmonticone

simplevaluegraphs.jl's Issues

comparison with MetaGraphsNext.jl ?

How does this package compare to MetaGraphsNext.jl ?
Are there any differences in the targeted use-cases, because to me they look very similar ?

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

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.