コード例 #1
0
 public void Init()
 {
     _tg = new TwinGraph();
     _k  = new ABVertexStack();
     _v1 = new ABVertex(VertexType.A, _tg);
     _v2 = new ABVertex(VertexType.B, _tg);
 }
コード例 #2
0
 public void DerivedInit()
 {
     _g.AddVertex(_v1);
     _g.AddVertex(_v2);
     _g.AddEdge(_v1, _v2, false);
     _tg = new TwinGraph(_g);
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: matrixdisc/GraphFramework
        private static double FindMaxWeightEdgeIn(TwinGraph g0)
        {
            Arc maxElement = g0.Arcs.First.Value;
            LinkedList <Arc> arcsInGStar = new LinkedList <Arc>();

            foreach (var arc in g0.Arcs)
            {
                if (arc.Weight >= maxElement.Weight)
                {
                    if (arc.Weight > maxElement.Weight)
                    {
                        arcsInGStar = new LinkedList <Arc>();    //reset list of arcs to be added to GStar
                    }
                    arcsInGStar.AddLast(arc);
                    maxElement = arc;
                }
                else
                {
                    arc.IsInGStar = false;
                }
            }
            foreach (var arc in arcsInGStar)
            {
                arc.IsInGStar = true;
            }
            foreach (var outboundArc in g0.StartVertex.OutboundArcs)
            {
                outboundArc.IsInGStar = true;
            }
            foreach (var inboundArc in g0.EndVertex.InboundArcs)
            {
                inboundArc.IsInGStar = true;
            }
            return(maxElement.Weight);
        }
コード例 #4
0
        public static TwinGraph Generate2VertexExampleTwinGraph()
        {
            Graph     g  = Generate2VertexExampleGraph();
            TwinGraph tg = new TwinGraph(g);

            return(tg);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: matrixdisc/GraphFramework
        public static TwinGraph GenerateExampleWeightedTwinGraph2()
        {
            Graph g = GenerateExampleWeightedGraph2();

            Log.Info("Graph generated ===================================================");
            TwinGraph tg = new TwinGraph(g, true);

            return(tg);
        }
コード例 #6
0
        public static TwinGraph GenerateExampleTwinGraph0()
        {
            Graph g = GenerateExampleGraph0();

            Log.Info("Graph generated ===================================================");
            TwinGraph tg = new TwinGraph(g);

            return(tg);
        }
コード例 #7
0
 public void Init()
 {
     _tg = new TwinGraph();
     _g = new Graph();
     _v1 = new Vertex();
     _v2 = new Vertex();
     _precursor = new Vertex("p");
     _tv1 = new TwinVertex(_precursor, _tg);
     _tv2 = new TwinVertex(_precursor, _tg);
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: matrixdisc/GraphFramework
        private static TwinGraph GenerateG0StarFrom(TwinGraph g0)
        {
            double maxWeight           = FindMaxWeightEdgeIn(g0);
            double initialVertexWeight = maxWeight / 2;

            foreach (var tv in g0.Vertices)
            {
                tv.Precursor.DoubleWeight = initialVertexWeight;
            }
            TwinGraph g0Star = g0;

            return(g0Star);
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: matrixdisc/GraphFramework
        static void Main(string[] args)
        {
            var lh = new LoggingHelper();

            lh.ClearLogFile();
            Log.Info("=====================================================================");
            var       g0     = ExampleWeightedGraph.GenerateExampleWeightedTwinGraph2();
            TwinGraph g0Star = GenerateG0StarFrom(g0);

            _mAugmentingPath = new LinkedList <Arc>();
            var i = 0;
            var mAugmentingPaths = new LinkedList <LinkedList <Arc> >();

            while (true)
            {
                i++;
                Log.Info("ITERATION " + i + " =============================================");
                var k     = new ABVertexStack();
                var l     = new LinkedList <ABVertex>();
                var mdfsw = new MDFSW(g0Star, k, l);
                MDFSW._step = 0;

                _mAugmentingPath = mdfsw.Run();
                if (_mAugmentingPath == null)
                {
                    //Extension step instead of breaking
                    break;
                }
                mAugmentingPaths.AddLast(_mAugmentingPath);
                g0Star.SymmetricDifferenceWith(_mAugmentingPath);

                g0Star.LogArcsWeighted();
                g0Star.LogVerticesWeighted();
            }
            LogPaths(mAugmentingPaths);
        }
コード例 #10
0
 public void DerivedInit()
 {
     _v  = new Vertex();
     _tg = new TwinGraph();
     _tv = new TwinVertex(_v, _tg);
 }
コード例 #11
0
 public void Init()
 {
     _tg  = new TwinGraph();
     _abv = new ABVertex(VertexType.A, _tg);
 }