Пример #1
0
        /*public void Solve()
         * {
         *  UploadVertex();
         *
         *  List<GraphVertex> connectedVertex = new List<GraphVertex>();
         *
         *  List<GraphEdge> connectedEdges = new List<GraphEdge>();
         *
         *  while (true)
         *  {
         *      foreach (GraphVertex vertex in _vertex)
         *      {
         *          GraphEdge maxEdge = null;
         *          GraphVertex v = vertex;
         *          while (maxEdge.ConnectedVertex.Name.Equals("T"))
         *          {
         *              connectedVertex.Add(v);
         *              List<GraphEdge> connEdges = GetEdges(v);
         *
         *              while(connEdges != null)
         *              {
         *                  if (v.Name.Equals("S"))
         *                  {
         *                      //
         *                  }
         *                  v.mark = new object[2] { 0, 0 };
         *                  connectedVertex.Remove(v);
         *                  connEdges = GetEdges(connectedVertex[connectedVertex.Count - 1]);
         *              }
         *
         *              foreach (GraphEdge edge in connEdges)
         *              {
         *                  if (edge.Throughput > maxEdge.Throughput)
         *                  {
         *                      maxEdge = edge;
         *                  }
         *              }
         *              maxEdge.ConnectedVertex.mark = new object[2] { maxEdge.Throughput, vertex.Name };
         *              connectedEdges.Add(maxEdge);
         *              connectedVertex.Add(maxEdge.ConnectedVertex);
         *              v = maxEdge.ConnectedVertex;
         *          }
         *
         *          foreach(GraphEdge edge in connectedEdges)
         *          {
         *
         *          }
         *
         *          foreach (GraphVertex vert in connectedVertex)
         *          {
         *              if (v.Name.Equals("S"))
         *              {
         *                  continue;
         *              }
         *
         *              vert.mark = new object[2] { 0, 0 };
         *
         *          }
         *      }
         *  }
         * }*/

        private List <GraphEdge> GetEdges(GraphVertex vertex)
        {
            List <GraphEdge> edges = new List <GraphEdge>();

            foreach (GraphEdge edge in vertex.Edges)
            {
                if (Convert.ToInt32(edge.ConnectedVertex.mark[1]) != 0 && edge.Throughput > 0)
                {
                    edges.Add(edge);
                }
            }
            return(edges);
        }
Пример #2
0
 public void AddEdge(GraphVertex vertex, int throughput, int flow)
 {
     Edges.Add(new GraphEdge(vertex, throughput, flow));
 }
Пример #3
0
 public GraphEdge(GraphVertex connectedVertex, int throughput, int flow)
 {
     ConnectedVertex = connectedVertex;
     Throughput      = throughput;
     Flow            = flow;
 }