1#!/usr/bin/perl -w
2
3# test interface being compatible to Graph.pm so that Graph::Maker works:
4use Test::More;
5use strict;
6
7BEGIN
8   {
9   plan tests => 15;
10   chdir 't' if -d 't';
11   use lib '../lib';
12   use_ok ("Graph::Easy") or die($@);
13   };
14
15can_ok ('Graph::Easy', qw/
16  new
17
18  add_vertex
19  add_vertices
20  has_edge
21  vertices
22  add_path
23  add_cycle
24  /);
25
26#############################################################################
27my $graph = Graph::Easy->new();
28
29is (ref($graph), 'Graph::Easy');
30
31is ($graph->error(), '', 'no error yet');
32
33$graph->add_vertex('A');
34my $A = $graph->node('A');
35
36is (scalar $graph->vertices(), 1, '1 vertex');
37my @nodes = $graph->vertices();
38is ($nodes[0], $A, '1 vertex');
39
40my $edge = $graph->add_edge ('A', 'B');
41
42is ($graph->has_edge('A','B'), 1, 'has_edge()');
43is ($graph->has_edge($A,'B'),  1, 'has_edge()');
44is ($graph->has_edge('C','B'), 0, 'has_edge()');
45
46$graph->add_vertices('A','B','C');
47is (scalar $graph->vertices(), 3, '3 vertices');
48
49$graph->set_vertex_attribute('A','fill','#deadff');
50
51my $atr = $graph->get_vertex_attribute('A','fill');
52
53is ($atr, $A->attribute('fill'), 'attribute got set');
54
55#############################################################################
56## add_cycle and add_path
57#
58
59$graph = Graph::Easy->new();
60$graph->add_path('A','B','C');
61is (scalar $graph->vertices(), 3, '3 vertices');
62is (scalar $graph->edges(), 2, '2 vertices');
63
64$graph = Graph::Easy->new();
65$graph->add_cycle('A','B','C');
66is (scalar $graph->vertices(), 3, '3 vertices');
67is (scalar $graph->edges(), 3, '3 vertices');
68
69
70