private int MaxChannelsCountInNode(Node node) { var maxChannelsCountInNode = _network.Nodes .Select(checkNode => _network.GetChannel(checkNode.Id, node.Id)) .Count(channel => channel == null); return(maxChannelsCountInNode - 1); }
public void GetChannelShouldReturnChannelIfChannelFromFirstToSecondNodeExists() { // Arrange CreateTwoNodesForTests(); CreateChannelForTests(); // Act var result = _network.GetChannel(_node1.Id, _node2.Id); // Assert Assert.That(result, Is.Not.Null); Assert.IsTrue(result.FirstNodeId == _node1.Id || result.FirstNodeId == _node2.Id); Assert.IsTrue(result.SecondNodeId == _node1.Id || result.SecondNodeId == _node2.Id); }
public virtual double CountPrice(uint startId, uint destinationId) { if (startId == destinationId) { return(0.0); } var startNode = Network.GetNodeById(startId); var destinationNode = Network.GetNodeById(destinationId); var channel = Network.GetChannel(startId, destinationId); if (!startNode.IsActive || !destinationNode.IsActive || channel == null || channel.IsBusy) { return(double.PositiveInfinity); } return(1.0); }
private void SearchConnectedNodes(ICollection <Node> currentNetwork, Node node) { foreach (var linkedNodeId in node.LinkedNodesId) { var channel = _network.GetChannel(node.Id, linkedNodeId); if (currentNetwork.Any(n => n.Id == linkedNodeId) || channel.ChannelType == ChannelType.Satellite) { continue; } var linkedNode = _network.GetNodeById(linkedNodeId); currentNetwork.Add(linkedNode); SearchConnectedNodes(currentNetwork, linkedNode); } }