dono-sybrix/php-graph

Create graphs

Installs: 3 150

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

pkg:composer/dono-sybrix/php-graph

v0.0.2 2015-10-13 09:12 UTC

This package is not auto-updated.

Last update: 2026-01-18 01:54:02 UTC


README

PHPGraph allow you to create conditional graphs in PHP.

    // Init a graph
    $graph = new \PHPGraph\Graph();
    
    // Create nodes
    $graph->createNode('Gender');
    $graph->createNode('Hall A');
    $graph->createNode('Hall B');
    $graph->createNode('Hall C');
    
    // Create links.
    $graph->link('Gender', 'Hall A')
        ->addCondition($user->size, '>=', 1.90)
        ->addConsequence('car_color', 'red');
        
    $graph->link('Gender', 'Hall B')
        ->createConditionGroup('&&')
            ->addCondition($user->size, '>', 1.60)
            ->addCondition($user->size, '<', 1.90 )
        ->close()
        ->addConsequence('car_color', 'orange');
        
    $graph->link('Gender', 'Hall C')
        ->addCondition($user->size, '<', 1.60)
        ->addConsequence('car_color', 'yellow');
        
    // Get data (consequences executed, nodes visited, etc)
    $results = $graph->visit();

Installation

You need Composer installed :

$ composer require dono-sybrix/php-graph