1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

Boost Graph

Description

In mathematics and computer science, graph theory studies networks of connected nodes and their properties. A graph can be used to visualize related data, or to find the shortest path from one node to another node for example.

The Boost Graph library is a comprehensible wrapper for the graph functionalities in Boost. Boost is a large C++ project with various useful libraries. The library offers the Boost graphing functions for small networks to people that are used to NodeBox code. The library is bundled with the BGL code files.

Also see the Graphing example in the Gallery for more information.

Does not work on NodeBox 1.9.2 or up, we recommend the newer Graph library.

Download

downloadPowerPC |Intel (1.5MB)
Last updated for NodeBox 1.9.1.1
Author: Tom De Smedt

Documentation

 

graph3

 


How to get the library up and running

Put the boostgraph library folder in the same folder as your script so NodeBox can find the library. You can also put it in ~/Library/Application Support/NodeBox/.

boostgraph = ximport("boostgraph")

Note: you will see a file named libboost_python.dylib appear in the folder from which you are running your script. The graph library needs this file to operate properly.

 


Creating a network of connected nodes

create(x, y, w, h, style="default")

The create() command returns a new Graph object encompassing the area starting at position x, y and having width w and height h. With the optional style parameter you can control the visual look of the graph. You can supply the name of style stored in the /styles subfolder as a string, or your own customized Style object.

The returned Graph object has the following properties:

  • graph.nodes: a list of all Node objects in the graph.
  • graph.style: the Style object describing the visual style of the graph.

You can add nodes (e.g. blocks of information you want to connect) to the graph with the graph.add_node() method. You can connect two nodes with the graph.add_edge() method:

graph.add_node(id, type=None)
graph.add_edge(id1, id2)

The id parameters are string labels which uniquely identify each node. They will appear as labels on each node once the graph is visualized.

You can retrieve a Node object from the graph with the graph.find() method:

graph.find(