Skip to content

Commit

Permalink
misc cleanups
Browse files Browse the repository at this point in the history
doc cleanup

file hierarchy

docs

changes to is_directed
  • Loading branch information
sbromberger committed Jul 11, 2015
1 parent e3c8b21 commit 031c283
Show file tree
Hide file tree
Showing 34 changed files with 203 additions and 120 deletions.
5 changes: 3 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
The LightGraphs.jl package is licensed under the Simplified "2-clause" BSD License:
The LightGraphs.jl package is licensed under the Simplified "2-clause" BSD
License:
> Copyright (c) 2015: Seth Bromberger and other contributors.
>
> Redistribution and use in source and binary forms, with or without
Expand All @@ -23,7 +24,7 @@ The LightGraphs.jl package is licensed under the Simplified "2-clause" BSD Licen
> (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
LightGraphs uses code derived from / inspired by the following packages:
LightGraphs uses code derived from and/or inspired by the following packages:

NetworkX:
> Copyright (C) 2004-2012, NetworkX Developers
Expand Down
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@

An optimized graphs package.

Simple graphs (not multi- or hypergraphs) are represented in a memory- and time-efficient
manner with adjacency lists and edge sets. Both directed and undirected graphs are supported via separate types, and conversion is available from directed to undirected.
Simple graphs (not multi- or hypergraphs) are represented in a memory- and
time-efficient manner with adjacency lists and edge sets. 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](http://networkx.github.io) while being simpler
to use and more efficient than existing Julian graph libraries such as
analysis libraries such as [NetworkX](http://networkx.github.io) while being
simpler to use and more efficient than existing Julian graph libraries such as
[Graphs.jl](https://github.com/JuliaLang/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
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.

Expand All @@ -33,11 +35,15 @@ Edges must be unique; an attempt to add an edge that already exists in a graph
will result in an error.

Edge distances for most traversals may be passed in as a sparse or dense matrix
of `Float64` values, indexed by `[src,dst]` vertices. That is, `distmx[2,4] = 2.5`
assigns the distance `2.5` to the (directed) edge connecting vertex 2 and vertex 4.
Note that for undirected graphs, `distmx[4,2]` should also be set.
of `Float64` values, indexed by `[src,dst]` vertices. That is,
`distmx[2,4] = 2.5` assigns the distance `2.5` to the (directed) edge
connecting vertex 2 and vertex 4. Note that for undirected graphs,
`distmx[4,2]` should also be set.

Edge distances for undefined edges are ignored, and edge distances cannot be zero: any unassigned values (for sparse matrices) or zero values (for sparse or dense matrices) in the edge distance matrix are assumed to be the default distance of 1.0.
Edge distances for undefined edges are ignored, and edge distances cannot be
zero: any unassigned values (for sparse matrices) or zero values (for sparse or
dense matrices) in the edge distance matrix are assumed to be the default
distance of 1.0.

### Basic Usage
(all examples apply equally to `DiGraph` unless otherwise noted):
Expand Down Expand Up @@ -93,7 +99,7 @@ write(g,"mygraph.jgz")
- bipartite checks
- condensation
- attracting components

- operators
- complement
- reverse, reverse!
Expand Down
7 changes: 4 additions & 3 deletions doc/about.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
*LightGraphs.jl* takes its inspiration from the excellent
[NetworkX](http://networkx.github.io) project. Many of the features in *NetworkX* have been replicated in *LightGraphs*.
[NetworkX](http://networkx.github.io) project. Many of the features in
*NetworkX* have been replicated in *LightGraphs*.

The project goal is to mirror the functionality of robust network and graph
analysis libraries such as [NetworkX](http://networkx.github.io) while being simpler
to use and more efficient than existing Julian graph libraries such as
analysis libraries such as [NetworkX](http://networkx.github.io) while being
simpler to use and more efficient than existing Julian graph libraries such as
[Graphs.jl](https://github.com/JuliaLang/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
Expand Down
16 changes: 11 additions & 5 deletions doc/basicmeasures.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
The following basic measures have been implemented for `Graph` and `DiGraph` types:
The following basic measures have been implemented for `Graph` and `DiGraph`
types:

### Vertices and Edges

Expand Down Expand Up @@ -36,7 +37,8 @@ Returns the source or destination vertex of edge `e`.
Returns an edge whose source and destination are switched from edge `e`.

`==(e, f)`
Will return true if edges `e` and `f` have the same source and destination vertices.
Will return true if edges `e` and `f` have the same source and destination
vertices.

### Neighbors and Degree

Expand All @@ -58,17 +60,21 @@ Returns the maximum (minimum) outdegree of `g` across all vertices.
Returns the maximum (minimum) indegree of `g` across all vertices.

`degree_histogram(g)`
Produces a histogram of degree values across all vertices for the graph `g`. The number of histogram buckets is based on the number of vertices in `g`.
Produces a histogram of degree values across all vertices for the graph `g`.
The number of histogram buckets is based on the number of vertices in `g`.

`density(g)`
Returns the density of graph `g`. Density is defined as the ratio of the number of actual edges to the number of possible edges (`(|v| |v-1|)` for directed graphs, `(|v| |v-1|) / 2` for undirected graphs).
Returns the density of graph `g`. Density is defined as the ratio of the number
of actual edges to the number of possible edges (`(|v| |v-1|)` for directed
graphs, `(|v| |v-1|) / 2` for undirected graphs).

`neighbors(g, v)`
Returns a list of all neighbors of vertex `v` in `g`.

`in_neighbors(g, v)`
`out_neighbors(g, v)`
Returns a list of all neighbors connected to vertex `v` by an outgoing (incoming) edge.
Returns a list of all neighbors connected to vertex `v` by an outgoing
(incoming) edge.

`common_neighbors(g, u, v)`
Returns the neighbors common to vertices `u` and `v` in `g`.
7 changes: 5 additions & 2 deletions doc/centrality.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Centrality Measures

[Centrality measures](https://en.wikipedia.org/wiki/Centrality) describe the importance of a vertex to the rest of the graph using some set of criteria. Centrality measures implemented in *LightGraphs.jl* include the following:
[Centrality measures](https://en.wikipedia.org/wiki/Centrality) describe the
importance of a vertex to the rest of the graph using some set of criteria.
Centrality measures implemented in *LightGraphs.jl* include the following:

###Degree Centrality
`degree_centrality(g[, normalize=true])`
`indegree_centrality(g[, normalize=true])`
`outdegree_centrality(g[, normalize=true)`
Calculates the [degree centrality](https://en.wikipedia.org/wiki/Centrality#Degree_centrality) of the graph `g`, with optional (default) normalization.
Calculates the [degree centrality](https://en.wikipedia.org/wiki/Centrality#Degree_centrality)
of the graph `g`, with optional (default) normalization.

###Closeness Centrality
`closeness_centrality(g[, normalize=true])`
Expand Down
33 changes: 24 additions & 9 deletions doc/distance.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,49 @@

`eccentricity(g, v[, distmx])`
`eccentricity(g[, vs, distmx])`
Calculates the eccentricity[ies] of a vertex `v`, vertex vector `vs`, or the entire graph. An optional matrix of edge distances may be supplied.
Calculates the eccentricity[ies] of a vertex `v`, vertex vector `vs`, or the
entire graph. An optional matrix of edge distances may be supplied.

The eccentricity of a vertex is the maximum shortest-path distance between it and all other vertices in the graph.
The eccentricity of a vertex is the maximum shortest-path distance between it
and all other vertices in the graph.

Because this function must calculate shortest paths for all vertices supplied in the argument list, it may take a long time.
Because this function must calculate shortest paths for all vertices supplied
in the argument list, it may take a long time.

The output is either a single float (when a single vertex is provided) or a vector of floats corresponding to the vertex vector. If no vertex vector is provided, the vector returned corresponds to each vertex in the graph.
The output is either a single float (when a single vertex is provided) or a
vector of floats corresponding to the vertex vector. If no vertex vector is
provided, the vector returned corresponds to each vertex in the graph.

Note that the eccentricity vector returned by `eccentricity()` may be used as input for the rest of the distance measures below. If an eccentricity vector is provided, it will be used. Otherwise, an eccentricity vector will be calculated for each call to the function. It may therefore be more efficient to calculate, store, and pass the eccentricities if multiple distance measures are desired.
Note that the eccentricity vector returned by `eccentricity()` may be used as
input for the rest of the distance measures below. If an eccentricity vector is
provided, it will be used. Otherwise, an eccentricity vector will be calculated
for each call to the function. It may therefore be more efficient to calculate,
store, and pass the eccentricities if multiple distance measures are desired.



###Radius
`radius(ev)`
`radius(g[, distmx])`
Calculates the radius of a graph. The radius is defined as the minimum eccentricity of the graph.
Calculates the radius of a graph. The radius is defined as the minimum
eccentricity of the graph.

###Diameter
`diameter(ev)`
`diameter(g[, distmx])`
Calculates the diameter of a graph. The diameter is defined as the maximum eccentricity of the graph.
Calculates the diameter of a graph. The diameter is defined as the maximum
eccentricity of the graph.

###Center
`center(ev)`
`center(g[, distmx])`
Calculates the center of a graph. The center of a graph is the set of all vertices whose eccentricity is equal to the graph's radius (that is, the set of vertices with the smallest eccentricity).
Calculates the center of a graph. The center of a graph is the set of all
vertices whose eccentricity is equal to the graph's radius (that is, the set of
vertices with the smallest eccentricity).

###Periphery
`periphery(ev)`
`periphery(g[, distmx])`
Calculates the periphery of a graph. The periphery of a graph is the set of all vertices whose eccentricity is equal to the graph's diameter (that is, the set of vertices with the largest eccentricity).
Calculates the periphery of a graph. The periphery of a graph is the set of all
vertices whose eccentricity is equal to the graph's diameter (that is, the set
of vertices with the largest eccentricity).
30 changes: 19 additions & 11 deletions doc/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,44 @@

`erdos_renyi(n, p[, is_directed=false])`
Creates an [Erdős–Rényi](http://en.wikipedia.org/wiki/Erdős–Rényi_model) random
graph with `n` vertices. Edges are added between pairs of vertices with probability
`p`. Undirected graphs are created by default; use `is_directed=true` to override.
graph with `n` vertices. Edges are added between pairs of vertices with
probability `p`. Undirected graphs are created by default; use
`is_directed=true` to override.

Note also that Erdős–Rényi graphs may be generated quickly using the `Graph(nv, ne)`
constructor, which randomly includes `ne` edges from the set of vertices.
Note also that Erdős–Rényi graphs may be generated quickly using the
`Graph(nv, ne)` constructor, which randomly includes `ne` edges from the set of
vertices.


`watts_strogatz(n, k, β[, is_directed=false])`
Creates a [Watts-Strogatz](https://en.wikipedia.org/wiki/Watts_and_Strogatz_model)
small model random graph with `n` vertices, each with degree `k`. Edges are randomized per the model based on probability `β`. Undirected graphs are created
by default; use `is_directed=true` to override.
small model random graph with `n` vertices, each with degree `k`. Edges are
randomized per the model based on probability `β`. Undirected graphs are
created by default; use `is_directed=true` to override.

### Static Graphs
*LightGraphs.jl* also implements a collection of classic graph generators:


`CompleteGraph(n)`
`CompleteDiGraph(n)`
Creates a complete graph with `n` vertices. A complete graph has edges connecting each pair of vertices.
Creates a complete graph with `n` vertices. A complete graph has edges
connecting each pair of vertices.

`StarGraph(n)`
`StarDiGraph(n)`
Creates a star graph with `n` vertices. A star graph has a central vertex with edges to each other vertex.
Creates a star graph with `n` vertices. A star graph has a central vertex with
edges to each other vertex.

`PathGraph(n)`
`PathDiGraph(n)`
Creates a path graph with `n` vertices. A path graph connects each successive vertex by a single edge.
Creates a path graph with `n` vertices. A path graph connects each successive
vertex by a single edge.

`WheelGraph(n)`
`WheelDiGraph(n)`
Creates a wheel graph with `n` vertices. A wheel graph is a star graph with the outer vertices connected via a closed path graph.
Creates a wheel graph with `n` vertices. A wheel graph is a star graph with the
outer vertices connected via a closed path graph.

The following graphs are undirected only:

Expand Down Expand Up @@ -86,7 +93,8 @@ A [Pappus graph](http://en.wikipedia.org/wiki/Pappus_graph).
A [Petersen graph](http://en.wikipedia.org/wiki/Petersen_graph).

`SedgewickMazeGraph()`
A simple maze graph used in Sedgewick's `Algorithms in C++: Graph Algorithms (3rd ed.)`
A simple maze graph used in Sedgewick's `Algorithms in C++: Graph Algorithms
(3rd ed.)`

`TetrahedralGraph()`
A [Platonic tetrahedral graph](https://en.wikipedia.org/wiki/Platonic_graph).
Expand Down
11 changes: 7 additions & 4 deletions doc/gettingstarted.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
### 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 stored as a set
of `Edge` types containing `(src::Int, dst::Int)` values. Edge
relationships are stored as forward and backward incidence vectors, indexed by
of `Edge` types containing `Pair(Int, Int)` values. Edge
relationships are stored as forward and backward adjacency vectors, indexed by
vertex.

*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 below for examples).

Expand All @@ -30,7 +33,6 @@ Note that for undirected graphs, `distmx[4,2]` should also be set.

Edge distances for undefined edges are ignored.

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

### Installation
Installation is straightforward:
Expand All @@ -43,9 +45,10 @@ julia> Pkg.install("LightGraphs")
- [Compat](https://github.com/JuliaLang/Compat.jl)
- [GZip](https://github.com/JuliaLang/GZip.jl)
- [StatsBase](https://github.com/JuliaStats/StatsBase.jl)
- [DataStructures](https://github.com/JuliaLang/DataStructures.jl)
- [Docile](https://github.com/MichaelHatherly/Docile.jl)

In addition, [LightXML](https://github.com/JuliaLang/LightXML.jl) is
recommended (required for GraphML support).

### Usage Examples
(all examples apply equally to `DiGraph` unless otherwise noted):
Expand Down
4 changes: 4 additions & 0 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

[![Build Status](https://travis-ci.org/JuliaGraphs/LightGraphs.jl.svg?branch=master)](https://travis-ci.org/JuliaGraphs/LightGraphs.jl)
[![Coverage Status](https://coveralls.io/repos/JuliaGraphs/LightGraphs.jl/badge.svg?branch=master)](https://coveralls.io/r/JuliaGraphs/LightGraphs.jl?branch=master)
[![LightGraphs](http://pkg.julialang.org/badges/LightGraphs_release.svg)](http://pkg.julialang.org/?pkg=LightGraphs&ver=release)
[![LightGraphs](http://pkg.julialang.org/badges/LightGraphs_0.4.svg)](http://pkg.julialang.org/?pkg=LightGraphs&ver=nightly)
[![Documentation Status](https://readthedocs.org/projects/lightgraphsjl/badge/?version=latest)](https://readthedocs.org/projects/lightgraphsjl/?badge=latest)
[![Join the chat at https://gitter.im/JuliaGraphs/LightGraphs.jl](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/JuliaGraphs/LightGraphs.jl)


An optimized graphs package.
Expand Down
7 changes: 4 additions & 3 deletions doc/integration.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*LightGraphs.jl* integration with other Julia packages is designed to be straightforward. Here are a few examples.
*LightGraphs.jl*'s integration with other Julia packages is designed to be straightforward. Here are a few examples.

### [Graphs.jl](http://github.com/JuliaLang/Graphs.jl)
Creating a Graphs.jl `simple_graph` is fairly straightforward:
Creating a Graphs.jl `simple_graph` is easy:
```julia
julia> s = simple_graph(nv(g), is_directed=LightGraphs.is_directed(g))
julia> for e in LightGraphs.edges(g)
Expand All @@ -10,7 +10,8 @@ julia> for e in LightGraphs.edges(g)
```

###[GraphLayout.jl](https://github.com/IainNZ/GraphLayout.jl)
This excellent graph visualization package can be used with *LightGraphs.jl* as follows:
This excellent graph visualization package can be used with *LightGraphs.jl*
as follows:

```julia
julia> g = WheelGraph(10); am = full(adjacency_matrix(g))
Expand Down
25 changes: 17 additions & 8 deletions doc/operators.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
*LightGraphs.jl* implements the following graph operators. In general, functions with two graph arguments will require them to be of the same type (either both `Graph` or both `DiGraph`).
*LightGraphs.jl* implements the following graph operators. In general,
functions with two graph arguments will require them to be of the same type
(either both `Graph` or both `DiGraph`).

`complement(g)`
Produces the [graph complement](https://en.wikipedia.org/wiki/Complement_graph) of a graph.
Produces the [graph complement](https://en.wikipedia.org/wiki/Complement_graph)
of a graph.

`reverse(g)`
(`DiGraph` only) Produces a graph where all edges are reversed from the original.
(`DiGraph` only) Produces a graph where all edges are reversed from the
original.

`reverse!(g)`
(`DiGraph` only) In-place reverse (modifies the original graph).

`blkdiag(g, h)`
Produces a graph with `|V(g)| + |V(h)|` vertices and `|E(g)| + |E(h)|` edges. Put simply, the vertices and edges from graph `h` are appended to graph `g`.
Produces a graph with `|V(g)| + |V(h)|` vertices and `|E(g)| + |E(h)|` edges.
Put simply, the vertices and edges from graph `h` are appended to graph `g`.

`intersect(g, h)`
Produces a graph with edges that are only in both graph `g` and graph `h`. Note that this function may produce a graph with 0-degree vertices.
Produces a graph with edges that are only in both graph `g` and graph `h`. Note
that this function may produce a graph with 0-degree vertices.

`difference(g, h)`
Produces a graph with edges in graph `g` that are not in graph `h`. Note that this function may produce a graph with 0-degree vertices.
Produces a graph with edges in graph `g` that are not in graph `h`. Note that
this function may produce a graph with 0-degree vertices.

`symmetric_difference(g, h)`
Produces a graph with edges from graph `g` that do not exist in graph `h`, and vice versa. Note that this function may produce a graph with 0-degree vertices.
Produces a graph with edges from graph `g` that do not exist in graph `h`, and
vice versa. Note that this function may produce a graph with 0-degree vertices.

`union(g, h)`
Merges graphs `g` and `h` by taking the set union of all vertices and edges.

`induced_subgraph(g, vs)`
`g[vs]`
Filters graph `g` to include only the vertices present in the iterable argument `vs`. Returns the subgraph of `g` induced by `vs`.
Filters graph `g` to include only the vertices present in the iterable argument
`vs`. Returns the subgraph of `g` induced by `vs`.
Loading

0 comments on commit 031c283

Please sign in to comment.