SixPairs.com SixPairs.com
A pandemonium of stuff about grammars, DSLs, graphs, povray, svg, xaml,
graphviz, intellipad, LaTeX, CLIPS, StringTemplate and Microsoft Oslo.
MGraph Object Model

MGraph Object Model Display Library

A library that displays MGraph Object Models on a WPF Canvas.

Here is the documentation (a very succinct one, but contains all you need).

The MGraph Object Model is a general graph representation and manipulation mechanism where the representation part is usually textual.

This library takes the textual representation of a graph and visualizes it on a WPF Canvas.

cf. The MGraph Object Model article on MSDN.

Some examples (see the last item for the "Villagers" example of the aforementioned article):

For a self-referential annotation of the shapes and colors used, go to NodeKinds Legend

Composite node example:

Canvas canvas = new ObjectModel().Display("Person {Name=>'Ciper', 47, 'sixpairs\n.com'}");
generates the following canvases (depending on the direction and layout options used in the Display() overloads):

Return to examples

Collection example:

Canvas canvas = new ObjectModel().Display("Primes {1, 2, 3, 5, 7}");

Return to examples

Record example:

Canvas canvas = new ObjectModel().Display("Person {Name=>'Ciper', Age=>47, Site=>'sixpairs\n.com'}");

Return to examples

Tuple example:

Canvas canvas = new ObjectModel().Display("Person ('Ciper', 47, 'sixpairs\n.com')");

Return to examples

List example:

Canvas canvas = new ObjectModel().Display("Fibonacci[1,1,2]");

Return to examples

Another list example:

Canvas canvas = new ObjectModel().Display(@"
                  Fibonacci { Head => 1,
                              Tail => { Head => 1,
                              Tail => { Head => 2,
                              Tail => {} } } }
                  ");

Return to examples

Simple "Villagers" example:

Canvas canvas = new ObjectModel().Display(@"
                            Villagers => {
                                Jenn => Person { Name => 'Jennifer', Age => 28, Spouse=>Rich },
                                Rich => Person { Name => 'Richard', Age => 26, Spouse =>Jenn },
                            }
                            ");

Return to examples

Villagers example:

Canvas canvas = new ObjectModel().Display(@"
                            {
                            Villagers => {
                              Jenn => Person { Name => 'Jennifer', Age => 28, Spouse => Rich },
                              Rich => Person { Name => 'Richard', Age => 26, Spouse => Jenn },
                              Charly => Person { Name => 'Charlotte', Age => 12 }
                            },
                            HaveSpouses => { Villagers.Rich, Villagers.Jenn }
                            }
                            ");

Return to examples

NodeKinds Legend:

Canvas canvas = new ObjectModel().Display(@"
                                    NodeKind {
                                        Record => R { F1=>'a', F2=>1 },
                                        Collection => C { 'a', 1},
                                        Tuple => T ('a', 1),
                                        List => L [ 'a', 1 ],
                                        Composite => C { F1 => 'a', 1 },
                                        Atomic => 42,
                                    }
                            ");

Go to examples

Contact Ceyhun Ciper
© 2009 Ceyhun Ciper
ceyhunc@gmail.com