planar-dual
Version:
Find the faces of a planar graph
53 lines (40 loc) • 836 B
Markdown
planar-dual
===========
Given a planar embedding of a graph, find all faces.
```javascript
var getFaces = require("planar-dual")
//Create a triforce
var positions = [
[],
[-1, -1],
[],
[]
]
var edges = [
[],
[],
[],
[],
[],
[]
]
//Compute dual graph
console.log(getFaces(edges, positions))
```
Output:
```javascript
[ [ 0, 1, 2 ], [ 0, 2, 3 ], [ 0, 3, 1 ], [ 1, 3, 2 ] ]
```
```
npm install planar-dual
```
Splits an embedded planar graph into a collection of faces
* `edges` are the edges of the graph
* `positions` are the locations of the vertices of the graph
**Returns** A list of faces of the graph represented as ordered lists of vertices
(c) 2014 Mikola Lysenko. MIT License