Skip to content

Commit 137e27b

Browse files
committed
Update README.md
1 parent 99e8300 commit 137e27b

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# Graphoon
22

3-
A force directed algorithm written in Lua.
3+
A force directed graph algorithm written in Lua.
44

5+
## Introduction
6+
7+
_Graphoon_ emerged from the graph calculation code used in both [LoGiVi](https://github.com/rm-code/logivi) and [LoFiVi](https://github.com/rm-code/lofivi).
8+
9+
A force directed graph layout is achieved by simulating physical forces, which push and pull each node in the graph until a nice layout is found.
510

611
## Basic Usage
712

813
The basic idea is that you create a new graph object, to which you can then add nodes and edges.
914

10-
```
15+
```lua
1116
local GraphLibrary = require('Graphoon').Graph
1217

1318
graph = GraphLibrary.new()
@@ -20,9 +25,9 @@ By itself Graphoon only provides functionality for creating the graph and calcul
2025

2126
It provides a ```draw``` and ```update``` function, which can be used to easily write your own rendering code.
2227

23-
The ```draw``` function should be called with two callback functions. The first callback will be used for all nodes and the second one for all the edges.
28+
The ```draw``` function should be called with two callback functions. The first callback will be used for all nodes and the second one for all the edges.
2429

25-
```
30+
```lua
2631
graph:draw( function( node )
2732
local x, y = node:getPosition()
2833
drawCircle( 'fill', x, y, 10 )
@@ -44,15 +49,14 @@ Anchors can be used to attach a node to a certain position on the screen. This c
4449

4550
This can either be done directly via the constructor of the node:
4651

47-
```
52+
```lua
4853
-- Anchor the node to the center of the screen.
4954
graph:addNode( "Ash Williams", screenX * 0.5, screenY * 0.5, true )
5055
```
5156

5257
Or by using the ```setAnchor``` function:
5358

54-
```
59+
```lua
5560
-- Invert anchor status
5661
node:setAnchor( not node:isAnchor() )
5762
```
58-

0 commit comments

Comments
 (0)