0

我正在与客户、零售商和供应商建立供应链模型。它们连接在一个节点中。我找到了这段代码。但我不明白,为什么这段代码会产生双倍的外缘。也许,有人可以帮忙吗?

      while (it.hasNext()) {
                // Find the next agent to link to.
                tempAgent = (supply_chain_agent) it.next();
                System.out.println(tempAgent);


                // Create an edge from the last agent to the temp agent.
                tempEdge = new supply_chain_edge("Orders", 1, this.initialOrderPerTimeStep);

                // Connect the new edge.
                tempAgent.addInEdge(tempEdge);
                System.out.println(tempEdge.getLabel());

                lastAgent.addOutEdge(tempEdge);
                System.out.println(tempEdge.getLabel());

                tempEdge.setTo(tempAgent);
                tempEdge.setFrom(lastAgent);

                // Create an edge from the temp agent to the last agent.
                if (lastAgent.getNodeLabel().startsWith("Customer")) {
                    tempEdge = new supply_chain_edge("Shipments", this.ordering_delay, this.initialOrderPerTimeStep);
                } else {
                    tempEdge = new supply_chain_edge("Shipments", this.delivery_delay, this.initialOrderPerTimeStep);
                }

                // Connect the new edge.
                lastAgent.addInEdge(tempEdge);
                System.out.println(tempEdge.getLabel());

                tempAgent.addOutEdge(tempEdge);
                System.out.println(tempEdge.getLabel());

                tempEdge.setTo(lastAgent);
                tempEdge.setFrom(tempAgent);

                // Move on.
                lastAgent = tempAgent;
                System.out.println(lastAgent);

            }
4

0 回答 0