This project is read-only.

How Can I Represent Graph Of Numbers Greater Than 10 Using Graphsharp Library?

Oct 29, 2015 at 8:31 PM
Edited Oct 29, 2015 at 8:35 PM
i am using graphSharp lib for my project . in which i need to represent more than 10 elements but it did not view properply . here is the code
    private void CreateGraphToVisualizenode()
    {
        var g = new BidirectionalGraph<object, IEdge<object>>();
        List<Class1> obj = new List<Class1>();
        //add the vertices to the graph
        for (int i = 0; i < 100; i++)
        {
            Class1 obj1 = new Class1(i,"n");
            obj.Add(obj1);

        }
        //add some edges to the graph

        for(int i=1;i<100;i++)
        {
            Color edgeColor = (i % 2 == 0) ? Colors.Black : Colors.Red;
            g.AddVerticesAndEdge(new MyEdge(obj[i - 1], obj[i]){
                Id = i.ToString(),
                EdgeColor = edgeColor });
        }
        g.AddVerticesAndEdge(new MyEdge(obj[99], obj[0]));
        _graphToVisualize = g;

    }
    public class MyEdge : TypedEdge<Object>
    {
        public String Id { get; set; }

        public Color EdgeColor { get; set; }

        public MyEdge(Object source, Object target) : base(source, target, EdgeTypes.General) { }
    }

    public class EdgeColorConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return new SolidColorBrush((Color)value);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
and xaml
<window x:class="GraphSharpTutorial01.Window1" xmlns:x="#unknown">
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:graphsharp="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
    xmlns:zoom="clr-namespace:WPFExtensions.Controls;assembly=WPFExtensions"
    Title="Window1"
    Height="400"
    Width="400"
    VerticalAlignment="Stretch"
    HorizontalAlignment="Stretch"
    x:Name="root"&gt;
<grid>

    <zoom:zoomcontrol xmlns:zoom="#unknown">
        <graphsharp:graphlayout x:name="graphLayout" xmlns:graphsharp="#unknown">
                                Graph="{Binding ElementName=root,Path=GraphToVisualize}"
                                LayoutAlgorithmType="FR"
                                OverlapRemovalAlgorithmType="FSA"
                                HighlightAlgorithmType="Simple"

                                /&gt;
    </graphsharp:graphlayout></zoom:zoomcontrol>
</grid>
</window>

and the solution isall node meged at single point. plz help.
Oct 30, 2015 at 1:20 AM
Hi, you have to use Layout() method of graphlayout control to generate graph, if i remember correctly. Btw, GraphSharp is abandoned for a long time, mind looking for GraphX if you want something fresh.