Getting Started

LightGraphs

Build Status codecov.io Join the chat at https://gitter.im/JuliaGraphs/LightGraphs.jl DOI

LightGraphs LightGraphs LightGraphs LightGraphs

An optimized graphs package.

Simple graphs (not multi- or hypergraphs) are represented in a memory- and time-efficient manner with adjacency lists and edge iterators. Both directed and undirected graphs are supported via separate types, and conversion is available from directed to undirected.

The project goal is to mirror the functionality of robust network and graph analysis libraries such as NetworkX while being simpler to use and more efficient than existing Julian graph libraries such as Graphs.jl. It is an explicit design decision that any data not required for graph manipulation (attributes and other information, for example) is expected to be stored outside of the graph structure itself. Such data lends itself to storage in more traditional and better-optimized mechanisms.

Additional functionality may be found in the companion package LightGraphsExtras.jl.

Documentation

Full documentation is available at GitHub Pages. Documentation for methods is also available via the Julia REPL help system. Additional tutorials can be found at JuliaGraphsTutorials.

Core Concepts

A graph G is described by a set of vertices V and edges E: G = {V, E}. V is an integer range 1:n; E is represented as forward (and, for directed graphs, backward) adjacency lists indexed by vertices. Edges may also be accessed via an iterator that yields Edge types containing (src<:Integer, dst<:Integer) values. Both vertices and edges may be integers of any type, and the smallest type that fits the data is recommended in order to save memory.

LightGraphs.jl provides two graph types: Graph is an undirected graph, and DiGraph is its directed counterpart.

Graphs are created using Graph() or DiGraph(); there are several options (see the tutorials for examples).

Multiple edges between two given vertices are not allowed: an attempt to add an edge that already exists in a graph will result in a silent failure.

Installation

Installation is straightforward:

julia> Pkg.add("LightGraphs")

Current functionality

symmetric difference, blkdiag, induced subgraphs, products (cartesian/scalar)

GraphPlot, Plots via PlotRecipes, GraphLayout, TikzGraphs, NetworkViz

Core API

These functions are defined as the public contract of the LightGraphs.AbstractGraph interface.

Constructing and modifying the graph

Edge/Arc interface

Accessing state

Non-Core APIs

These functions can be constructed from the Core API functions but can be given specialized implementations in order to improve performance.

This can be computed from neighbors by default degree(g,v) = length(neighbors(g,v)) so you don't need to implement this unless your type can compute degree faster than this method.

Supported Versions

Contributing and Reporting Bugs

We welcome contributions and bug reports! Please see CONTRIBUTING.md for guidance on development and bug reporting.