コード例 #1
0
ファイル: AdjacencyGraph.cs プロジェクト: timonela/mb-unit
		/// <summary>
		/// Builds a new empty directed graph with default vertex and edge
		/// provider.
		/// </summary>
		/// <remarks>
		/// </remarks>
		public AdjacencyGraph()
		{
			this.vertexProvider = new QuickGraph.Providers.VertexProvider();
			this.edgeProvider = new QuickGraph.Providers.EdgeProvider();
			this.allowParallelEdges = true;
			this.vertexOutEdges = new VertexEdgesDictionary();
		}
コード例 #2
0
ファイル: AdjacencyGraph.cs プロジェクト: tmauldin/mb-unit
 /// <summary>
 /// Builds a new empty directed graph with default vertex and edge
 /// provider.
 /// </summary>
 /// <remarks>
 /// </remarks>
 public AdjacencyGraph()
 {
     this.vertexProvider     = new QuickGraph.Providers.VertexProvider();
     this.edgeProvider       = new QuickGraph.Providers.EdgeProvider();
     this.allowParallelEdges = true;
     this.vertexOutEdges     = new VertexEdgesDictionary();
 }
コード例 #3
0
 /// <summary>
 /// Builds a new empty directed graph with default vertex and edge
 /// provider.
 /// </summary>
 /// <param name="allowParallelEdges">true if parallel edges are allowed</param>
 public PetriGraph(bool allowParallelEdges)
 {
     this.vertexProvider     = new QuickGraph.Providers.VertexProvider();
     this.edgeProvider       = new QuickGraph.Providers.EdgeProvider();
     this.allowParallelEdges = allowParallelEdges;
     this.vertexOutEdges     = new VertexEdgesDictionary();
 }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="graphType"></param>
        /// <param name="vertexProviderType"></param>
        /// <param name="edgeProviderType"></param>
        /// <param name="directed"></param>
        /// <param name="allowParallelEdges"></param>
        /// <returns></returns>
        protected ISerializableVertexAndEdgeListGraph CreateGraph(
            Type graphType,
            Type vertexProviderType,
            Type edgeProviderType,
            bool directed,
            bool allowParallelEdges
            )
        {
            // create providers
            IVertexProvider vp =
                (IVertexProvider)vertexProviderType.GetConstructor(Type.EmptyTypes).Invoke(null);
            IEdgeProvider ep =
                (IEdgeProvider)edgeProviderType.GetConstructor(Type.EmptyTypes).Invoke(null);

            // create graph
            Type[] gts = new Type[3];
            gts[0] = typeof(IVertexProvider);
            gts[1] = typeof(IEdgeProvider);
            gts[2] = typeof(bool);

            Object[] gps = new Object[3];
            gps[0] = vp;
            gps[1] = ep;
            gps[2] = allowParallelEdges;
            return((ISerializableVertexAndEdgeListGraph)graphType.GetConstructor(gts).Invoke(gps));
        }
コード例 #5
0
 /// <summary>
 /// Builds a new empty directed graph with default vertex and edge
 /// provider.
 /// </summary>
 /// <param name="allowParallelEdges">true if parallel edges are allowed</param>
 public PetriGraph(bool allowParallelEdges)
 {
     this.vertexProvider = new QuickGraph.Providers.VertexProvider();
     this.edgeProvider = new QuickGraph.Providers.EdgeProvider();
     this.allowParallelEdges = allowParallelEdges;
     this.vertexOutEdges = new VertexEdgesDictionary();
 }
コード例 #6
0
 /// <summary>
 /// Creates new instance of SequentialOrderingProblem class
 /// </summary>
 /// <param name="name">problem name</param>
 /// <param name="comment">comment on problem from the author</param>
 /// <param name="nodeProvider">provider of nodes</param>
 /// <param name="edgeProvider">provider of edges</param>
 /// <param name="edgeWeightsProvider">provider of edge weights</param>
 /// <param name="fixedEdgesProvider">provider of fixed edges</param>
 public SequentialOrderingProblem(string name,
                                  string comment,
                                  INodeProvider nodeProvider,
                                  IEdgeProvider edgeProvider,
                                  IEdgeWeightsProvider edgeWeightsProvider,
                                  IFixedEdgesProvider fixedEdgesProvider)
     : base(name, comment, ProblemType.SOP, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider)
 {
 }
コード例 #7
0
 /// <summary>
 /// Creates new instance of HamiltonianCycleProblem class
 /// </summary>
 /// <param name="name">problem name</param>
 /// <param name="comment">comment on problem from the author</param>
 /// <param name="nodeProvider">provider of nodes</param>
 /// <param name="edgeProvider">provider of edges</param>
 /// <param name="edgeWeightsProvider">provider of edge weights</param>
 /// <param name="fixedEdgesProvider">provider of fixed edges</param>
 public HamiltonianCycleProblem(string name,
                                string comment,
                                INodeProvider nodeProvider,
                                IEdgeProvider edgeProvider,
                                IEdgeWeightsProvider edgeWeightsProvider,
                                IFixedEdgesProvider fixedEdgesProvider)
     : base(name, comment, ProblemType.HCP, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider)
 {
 }
コード例 #8
0
 /// <summary>
 /// Builds a new empty graph
 /// </summary>
 public BidirectionalGraph(
     IVertexProvider vertexProvider,
     IEdgeProvider edgeProvider,
     bool allowParallelEdges
     )
     : base(vertexProvider,edgeProvider,allowParallelEdges)
 {
     m_VertexInEdges = new VertexEdgesDictionary();
 }
コード例 #9
0
 /// <summary>
 /// Builds a new empty graph
 /// </summary>
 public BidirectionalGraph(
     IVertexProvider vertexProvider,
     IEdgeProvider edgeProvider,
     bool allowParallelEdges
     )
     : base(vertexProvider, edgeProvider, allowParallelEdges)
 {
     m_VertexInEdges = new VertexEdgesDictionary();
 }
コード例 #10
0
 /// <summary>
 /// Creates new instance of HamiltonianCycleProblem class
 /// </summary>
 /// <param name="name">problem name</param>
 /// <param name="comment">comment on problem from the author</param>
 /// <param name="nodeProvider">provider of nodes</param>
 /// <param name="edgeProvider">provider of edges</param>
 /// <param name="edgeWeightsProvider">provider of edge weights</param>
 /// <param name="fixedEdgesProvider">provider of fixed edges</param>
 public HamiltonianCycleProblem(string name,
     string comment,
     INodeProvider nodeProvider,
     IEdgeProvider edgeProvider,
     IEdgeWeightsProvider edgeWeightsProvider,
     IFixedEdgesProvider fixedEdgesProvider)
     : base(name, comment, ProblemType.HCP, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider)
 {
 }
コード例 #11
0
 /// <summary>
 /// Creates new instance of SequentialOrderingProblem class
 /// </summary>
 /// <param name="name">problem name</param>
 /// <param name="comment">comment on problem from the author</param>
 /// <param name="nodeProvider">provider of nodes</param>
 /// <param name="edgeProvider">provider of edges</param>
 /// <param name="edgeWeightsProvider">provider of edge weights</param>
 /// <param name="fixedEdgesProvider">provider of fixed edges</param>
 public SequentialOrderingProblem(string name,
                                  string comment,
                                  INodeProvider nodeProvider,
                                  IEdgeProvider edgeProvider,
                                  IEdgeWeightsProvider edgeWeightsProvider,
                                  IFixedEdgesProvider fixedEdgesProvider)
     : base(name, comment, ProblemType.SOP, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider)
 {
 }
コード例 #12
0
 /// <summary>
 /// Creates new instance of TravelingSalesmanProblem class
 /// </summary>
 /// <param name="name">problem name</param>
 /// <param name="comment">comment on problem from the author</param>
 /// <param name="type">TSP or ATSP</param>
 /// <param name="nodeProvider">provider of nodes</param>
 /// <param name="edgeProvider">provider of edges</param>
 /// <param name="edgeWeightsProvider">provider of edge weights</param>
 /// <param name="fixedEdgesProvider">provider of fixed edges</param>
 public TravelingSalesmanProblem(string name,
                                 string comment,
                                 ProblemType type,
                                 INodeProvider nodeProvider,
                                 IEdgeProvider edgeProvider,
                                 IEdgeWeightsProvider edgeWeightsProvider,
                                 IFixedEdgesProvider fixedEdgesProvider)
     : base(name, comment, type, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider)
 {
 }
コード例 #13
0
 /// <summary>
 /// Creates new instance of TravelingSalesmanProblem class
 /// </summary>
 /// <param name="name">problem name</param>
 /// <param name="comment">comment on problem from the author</param>
 /// <param name="type">TSP or ATSP</param>
 /// <param name="nodeProvider">provider of nodes</param>
 /// <param name="edgeProvider">provider of edges</param>
 /// <param name="edgeWeightsProvider">provider of edge weights</param>
 /// <param name="fixedEdgesProvider">provider of fixed edges</param>
 public TravelingSalesmanProblem(string name,
                                 string comment,
                                 ProblemType type,
                                 INodeProvider nodeProvider,
                                 IEdgeProvider edgeProvider,
                                 IEdgeWeightsProvider edgeWeightsProvider,
                                 IFixedEdgesProvider fixedEdgesProvider)
     : base(name, comment, type, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider)
 {
 }
コード例 #14
0
        /// <summary>
        /// Creates new instance of a node adjacency based weight provider
        /// </summary>
        /// <param name="edgeProvider">distance function to be used</param>
        /// <param name="adjacentWeight">weight for adjacent nodes</param>
        /// <param name="nonAdjacentWeight">weight for non-adjacent nodes</param>
        public NodeAdjacencyBasedWeightProvider(IEdgeProvider edgeProvider, double adjacentWeight, double nonAdjacentWeight)
        {
            if (edgeProvider == null)
            {
                throw new ArgumentNullException("edgeProvider");
            }

            this.EdgeProvider      = edgeProvider;
            this.AdjacentWeight    = adjacentWeight;
            this.NotAdjacentWeight = nonAdjacentWeight;
        }
コード例 #15
0
        /// <summary>
        /// Creates new instance of a node adjacency based weight provider
        /// </summary>
        /// <param name="edgeProvider">distance function to be used</param>
        /// <param name="adjacentWeight">weight for adjacent nodes</param>
        /// <param name="nonAdjacentWeight">weight for non-adjacent nodes</param>
        public NodeAdjacencyBasedWeightProvider(IEdgeProvider edgeProvider, double adjacentWeight, double nonAdjacentWeight)
        {
            if (edgeProvider == null)
            {
                throw new ArgumentNullException("edgeProvider");
            }

            this.EdgeProvider = edgeProvider;
            this.AdjacentWeight = adjacentWeight;
            this.NotAdjacentWeight = nonAdjacentWeight;
        }
コード例 #16
0
 public AdjacencyGraph(IVertexProvider vertexProvider, IEdgeProvider edgeProvider, bool allowParallelEdges)
 {
     if (vertexProvider == null)
     {
         throw new ArgumentNullException("vertex provider");
     }
     if (edgeProvider == null)
     {
         throw new ArgumentNullException("edge provider");
     }
     this.vertexProvider = vertexProvider;
     this.edgeProvider = edgeProvider;
     this.allowParallelEdges = allowParallelEdges;
     this.vertexOutEdges = new VertexEdgesDictionary();
 }
コード例 #17
0
        /// <summary>
        /// Builds a new empty directed graph with custom providers
        /// </summary>
        /// <param name="allowParallelEdges">true if the graph allows
        /// multiple edges</param>
        /// <param name="edgeProvider">custom edge provider</param>
        /// <param name="vertexProvider">custom vertex provider</param>
        /// <exception cref="ArgumentNullException">
        /// vertexProvider or edgeProvider is a null reference
        /// </exception>
        public PetriGraph(
            IVertexProvider vertexProvider,
            IEdgeProvider edgeProvider,
            bool allowParallelEdges
            )
        {
            if (vertexProvider == null)
            {
                throw new ArgumentNullException("vertex provider");
            }
            if (edgeProvider == null)
            {
                throw new ArgumentNullException("edge provider");
            }

            this.vertexProvider     = vertexProvider;
            this.edgeProvider       = edgeProvider;
            this.allowParallelEdges = allowParallelEdges;
            this.vertexOutEdges     = new VertexEdgesDictionary();
        }
コード例 #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        protected void ReadGraphXml(XmlReader reader)
        {
            if (!reader.Read() || reader.Name != "graph")
            {
                throw new Exception("could not find graph node");
            }

            // getting types
            MoveToAttribute(reader, "type");
            Type graphType = Type.GetType(reader.Value, true);

            MoveToAttribute(reader, "vertex-provider-type");
            Type vertexProviderType = Type.GetType(reader.Value, true);

            MoveToAttribute(reader, "edge-provider-type");
            Type edgeProviderType = Type.GetType(reader.Value, true);

            MoveToAttribute(reader, "directed");
            bool directed = bool.Parse(reader.Value);

            MoveToAttribute(reader, "allow-parallel-edges");
            bool allowParallelEdges = bool.Parse(reader.Value);

            // create providers
            IVertexProvider vp = (IVertexProvider)vertexProviderType.GetConstructor(Type.EmptyTypes).Invoke(null);
            IEdgeProvider   ep = (IEdgeProvider)edgeProviderType.GetConstructor(Type.EmptyTypes).Invoke(null);

            // create graph
            Type[] gts = new Type[3];
            gts[0] = typeof(IVertexProvider);
            gts[1] = typeof(IEdgeProvider);
            gts[2] = typeof(bool);

            Object[] gps = new Object[3];
            gps[0] = vp;
            gps[1] = ep;
            gps[2] = allowParallelEdges;
            Graph  = (ISerializableVertexAndEdgeListGraph)graphType.GetConstructor(gts).Invoke(gps);
        }
コード例 #19
0
        /// <summary>
        /// Creates new instance of CapacitatedVehicleRoutingProblem class
        /// </summary>
        /// <param name="name">problem name</param>
        /// <param name="comment">comment on problem from the author</param>
        /// <param name="nodeProvider">provider of nodes</param>
        /// <param name="edgeProvider">provider of edges</param>
        /// <param name="edgeWeightsProvider">provider of edge weights</param>
        /// <param name="fixedEdgesProvider">provider of fixed edges</param>
        /// <param name="depotsProvider">provider of depot nodes</param>
        /// <param name="demandProvider">provider of demands on nodes</param>
        public CapacitatedVehicleRoutingProblem(string name,
                                                string comment,
                                                INodeProvider nodeProvider,
                                                IEdgeProvider edgeProvider,
                                                IEdgeWeightsProvider edgeWeightsProvider,
                                                IFixedEdgesProvider fixedEdgesProvider,
                                                IDepotsProvider depotsProvider,
                                                IDemandProvider demandProvider)
            : base(name, comment, ProblemType.CVRP, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider)
        {
            if (depotsProvider == null)
            {
                throw new ArgumentNullException("depotsProvider");
            }

            if (demandProvider == null)
            {
                throw new ArgumentNullException("demandProvider");
            }

            DepotsProvider = depotsProvider;
            DemandProvider = demandProvider;
        }
コード例 #20
0
        /// <summary>
        /// Creates new instance of CapacitatedVehicleRoutingProblem class
        /// </summary>
        /// <param name="name">problem name</param>
        /// <param name="comment">comment on problem from the author</param>
        /// <param name="nodeProvider">provider of nodes</param>
        /// <param name="edgeProvider">provider of edges</param>
        /// <param name="edgeWeightsProvider">provider of edge weights</param>
        /// <param name="fixedEdgesProvider">provider of fixed edges</param>
        /// <param name="depotsProvider">provider of depot nodes</param>
        /// <param name="demandProvider">provider of demands on nodes</param>
        public CapacitatedVehicleRoutingProblem(string name,
                                                string comment,
                                                INodeProvider nodeProvider,
                                                IEdgeProvider edgeProvider,
                                                IEdgeWeightsProvider edgeWeightsProvider,
                                                IFixedEdgesProvider fixedEdgesProvider,
                                                IDepotsProvider depotsProvider,
                                                IDemandProvider demandProvider)
            : base(name, comment, ProblemType.CVRP, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider)
        {
            if (depotsProvider == null)
            {
                throw new ArgumentNullException("depotsProvider");
            }

            if (demandProvider == null)
            {
                throw new ArgumentNullException("demandProvider");
            }

            DepotsProvider = depotsProvider;
            DemandProvider = demandProvider;
        }
コード例 #21
0
        /// <summary>
        /// Creates new instance of ProblemBase class
        /// </summary>
        /// <param name="name">Problem name</param>
        /// <param name="comment">Comment on problem</param>
        /// <param name="type">The problem type (TSP, ATSP, etc)</param>
        /// <param name="nodeProvider">Provider of graph nodes</param>
        /// <param name="edgeProvider">Provider of graph edges</param>
        /// <param name="edgeWeightsProvider">Provider of edge weights</param>
        /// <param name="fixedEdgesProvider">Provider of solution fixed edges</param>
        protected ProblemBase(string name,
                              string comment,
                              ProblemType type,
                              INodeProvider nodeProvider,
                              IEdgeProvider edgeProvider,
                              IEdgeWeightsProvider edgeWeightsProvider,
                              IFixedEdgesProvider fixedEdgesProvider)
        {
            if (nodeProvider == null)
            {
                throw new ArgumentNullException("nodeProvider");
            }

            if (edgeProvider == null)
            {
                throw new ArgumentNullException("edgeProvider");
            }

            if (edgeWeightsProvider == null)
            {
                throw new ArgumentNullException("edgeWeightsProvider");
            }

            if (fixedEdgesProvider == null)
            {
                throw new ArgumentNullException("fixedEdgesProvider");
            }

            Name = name;
            Comment = comment;
            Type = type;
            NodeProvider = nodeProvider;
            EdgeProvider = edgeProvider;
            EdgeWeightsProvider = edgeWeightsProvider;
            FixedEdgesProvider = fixedEdgesProvider;
        }
コード例 #22
0
        /// <summary>
        /// Creates new instance of ProblemBase class
        /// </summary>
        /// <param name="name">Problem name</param>
        /// <param name="comment">Comment on problem</param>
        /// <param name="type">The problem type (TSP, ATSP, etc)</param>
        /// <param name="nodeProvider">Provider of graph nodes</param>
        /// <param name="edgeProvider">Provider of graph edges</param>
        /// <param name="edgeWeightsProvider">Provider of edge weights</param>
        /// <param name="fixedEdgesProvider">Provider of solution fixed edges</param>
        protected ProblemBase(string name,
                              string comment,
                              ProblemType type,
                              INodeProvider nodeProvider,
                              IEdgeProvider edgeProvider,
                              IEdgeWeightsProvider edgeWeightsProvider,
                              IFixedEdgesProvider fixedEdgesProvider)
        {
            if (nodeProvider == null)
            {
                throw new ArgumentNullException("nodeProvider");
            }

            if (edgeProvider == null)
            {
                throw new ArgumentNullException("edgeProvider");
            }

            if (edgeWeightsProvider == null)
            {
                throw new ArgumentNullException("edgeWeightsProvider");
            }

            if (fixedEdgesProvider == null)
            {
                throw new ArgumentNullException("fixedEdgesProvider");
            }

            Name                = name;
            Comment             = comment;
            Type                = type;
            NodeProvider        = nodeProvider;
            EdgeProvider        = edgeProvider;
            EdgeWeightsProvider = edgeWeightsProvider;
            FixedEdgesProvider  = fixedEdgesProvider;
        }