예제 #1
0
        public AdjacencyList <T, TNode> Reverse()
        {
            var result = new AdjacencyList <T, TNode>(_nodeFactory);

            foreach (var adjacency in _adjacencies.Values)
            {
                foreach (var edge in adjacency)
                {
                    result.AddEdge(edge.Target.Value, edge.Source.Value, edge.Weight);
                }
            }

            return(result);
        }
예제 #2
0
        public AdjacencyList <T, TResultNode> Transform <TResultNode>(Func <int, T, TResultNode> nodeFactory)
            where TResultNode : Node <T>
        {
            var result = new AdjacencyList <T, TResultNode>(nodeFactory);

            foreach (var adjacency in _adjacencies.Values)
            {
                foreach (var edge in adjacency)
                {
                    result.AddEdge(edge.Source.Value, edge.Target.Value, edge.Weight);
                }
            }

            return(result);
        }
예제 #3
0
 public void Add(T source, T target)
 {
     _adjacencyList.AddEdge(source, target, 0);
 }