Skip to content

Commit c3d6975

Browse files
committed
Merge branch 'master' of github.com:datavis-tech/graph-data-structure
2 parents 39864f2 + 7bcc8d8 commit c3d6975

1 file changed

Lines changed: 28 additions & 15 deletions

File tree

README.md

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,36 @@ A [graph data structure](https://en.wikipedia.org/wiki/Graph_(abstract_data_type
44

55
[![NPM](https://nodei.co/npm/graph-data-structure.png)](https://npmjs.org/package/graph-data-structure)
66
[![NPM](https://nodei.co/npm-dl/graph-data-structure.png?months=3)](https://npmjs.org/package/graph-data-structure)
7+
[![Build Status](https://travis-ci.org/datavis-tech/graph-data-structure.svg?branch=master)](https://travis-ci.org/datavis-tech/graph-data-structure)
78

89
This library provides a minimalist implementation of a directed graph data structure. Nodes are represented by unique strings. Internally, an [adjacency list](https://en.wikipedia.org/wiki/Adjacency_list) is used to represent nodes and edges.
910

1011
The primary use case for this library is in implementing [dataflow programming](https://en.wikipedia.org/wiki/Dataflow_programming) or [reactive programming](https://en.wikipedia.org/wiki/Reactive_programming). The key algorithm necessary for these is topological sorting, to get an ordering of nodes such that for each edge (**u** -> **v**), **u** comes before **v** in the sorted order. The topological sorting algorithm exposed here has modifications useful for computing the order in which functions in a data flow graph should be executed, namely specifying source nodes for propagation and specifying to exclude the source nodes themselves from the result.
1112

13+
**Table of Contents**
14+
15+
* [Installing](#installing)
16+
* [Examples](#examples)
17+
* [ABC](#abc)
18+
* [Getting Dressed](#getting-dressed)
19+
* [API Reference](#api-reference)
20+
21+
## Installing
22+
23+
This library is distributed only via [NPM](npmjs.com). Install by running
24+
25+
`npm install graph-data-structure`
26+
27+
Require it in your code like this.
28+
29+
```javascript
30+
var Graph = require("graph-data-structure");
31+
```
32+
33+
## Examples
34+
35+
### ABC
36+
1237
To create a graph instance, invoke **[Graph](#graph)** as a constructor function.
1338

1439
```javascript
@@ -37,6 +62,8 @@ Now we have the following graph. <img src="https://cloud.githubusercontent.com/a
3762
graph.topologicalSort(); // Returns ["a", "b", "c"]
3863
```
3964

65+
### Getting Dressed
66+
4067
Here's an example of topological sort with getting dressed (from Cormen et al. "Introduction to Algorithms" page 550).
4168

4269
<p align="center">
@@ -60,21 +87,7 @@ console.log(graph.topologicalSort());
6087

6188
For more detailed example code that shows more methods, have a look at the [tests](https://github.com/datavis-tech/graph-data-structure/blob/master/test.js).
6289

63-
[![Build Status](https://travis-ci.org/datavis-tech/graph-data-structure.svg?branch=master)](https://travis-ci.org/datavis-tech/graph-data-structure)
64-
65-
# Installation
66-
67-
This library is distributed only via [NPM](npmjs.com). Install by running
68-
69-
`npm install graph-data-structure`
70-
71-
Require it in your code like this.
72-
73-
```javascript
74-
var Graph = require("graph-data-structure");
75-
```
76-
77-
# API Reference
90+
## API Reference
7891

7992
* [Creating a Graph](#creating-a-graph)
8093
* [Adding and Removing Nodes](#adding-and-removing-nodes)

0 commit comments

Comments
 (0)