Skip to content

Latest commit

 

History

354 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NamedGraphs.jl

Stable Dev Build Status Coverage Code Style Aqua

NamedGraphs.jl is an extension of Graphs.jl providing graph types with named vertices. The vertices of a NamedGraph or NamedDiGraph can be strings, tuples, or any other names, rather than the contiguous integers of a SimpleGraph. The goal is for named graphs to implement the functionality of Graphs.jl accounting for named vertices and edges, so see the Graphs.jl documentation for the available functionality and interface. Note that reaching feature parity with Graphs.jl is still in progress: for performance, functionality is often implemented by translating to the integer vertices and forwarding to the Graphs.jl implementation, which often assumes simple graphs (contiguous 1-based integer vertices), so functions need to be wrapped one by one. Please raise an issue if functionality you need is missing. The package also includes tools for working with partitioned graphs and their quotient graphs, and generic extensions of the Graphs.jl interface.

DataGraphs.jl builds on top of this package to provide named graphs with data associated with the vertices and edges.

Support

Flatiron Center for Computational Quantum Physics logo.

NamedGraphs.jl is supported by the Flatiron Institute, a division of the Simons Foundation.

Installation instructions

The package can be added as usual through the package manager:

julia> Pkg.add("NamedGraphs")

Examples

using Graphs: add_edge!, has_edge, has_vertex, ne, neighbors, nv, path_graph, vertices
using NamedGraphs: NamedGraph
using Test: @test

Construct a graph with named vertices:

g = NamedGraph(["a", "b", "c", "d"])
@test has_vertex(g, "a")
@test !has_vertex(g, "e")
@test nv(g) == 4

Add and check edges using the vertex names:

add_edge!(g, "a" => "b")
add_edge!(g, "b" => "c")
@test has_edge(g, "a" => "b")
@test has_edge(g, "b" => "a")
@test !has_edge(g, "a" => "c")
@test ne(g) == 2

Graphs.jl functions take and return the vertex names:

@test issetequal(neighbors(g, "b"), ["a", "c"])
@test collect(vertices(g)) == ["a", "b", "c", "d"]

The edge structure can also be supplied by a simple graph, with the ith vertex name corresponding to the vertex i of the simple graph:

g = NamedGraph(path_graph(4), ["a", "b", "c", "d"])
@test ne(g) == 3
@test has_edge(g, "a" => "b")

Contributors

This package is primarily developed by:


This page was generated using Literate.jl.

About

Extension of `Graphs.jl` to graphs with named vertices.

Resources

Stars

10 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages