コード例 #1
0
ファイル: GraphNode.cs プロジェクト: stevenandrewcarter/COG
 public void AddEdge(GraphNode destination)
 {
     GraphEdge e = new CommunicationGraphEdge(this, destination);
       if (!edges.Contains(e))
     edges.Add(e);
 }
コード例 #2
0
ファイル: Operator.cs プロジェクト: stevenandrewcarter/COG
 void messageQueue_BroadcastEvent(object sender, BroadcastMessageEventArgs e)
 {
     Message broadcastMessage = e.BroadcastMessage;
       CommunicationGraphNode aNode = broadcastMessage.Author.CommunicationNode;
       // Add new agent to Communication Graph
       if (communicationGraph.Add(aNode)) {
     // Set the Authors node to the graph node
     GraphEdge edge = new CommunicationGraphEdge(broadcastMessage.Author.CommunicationNode, communicationNode);
     if (!aNode.Edges.Contains(edge)) aNode.Edges.Add(edge);
     edge = new CommunicationGraphEdge(communicationNode, broadcastMessage.Author.CommunicationNode);
     if (!communicationNode.Edges.Contains(edge)) communicationNode.Edges.Add(edge);
     // Write a message to the agent informing it that the Operator is aware
     // of its existance
     Message aMessage = new InformMessage(this);
     messageQueue.SendPost(broadcastMessage.Author, aMessage);
     // Also inform the controller if this agent is not a controller
     if ((broadcastMessage.Author is Controller)) {
       manager = broadcastMessage.Author;
     }
       }
       broadcastMessage = null;    // Clear the message from the queue
 }