public void AddEdge(GraphNode destination) { GraphEdge e = new CommunicationGraphEdge(this, destination); if (!edges.Contains(e)) edges.Add(e); }
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 }