Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Vector
- {
- public Node from;
- public Node to;
- public float weight;
- public Vector(Node from, Node to, float weight)
- {
- this.from = from;
- this.to = to;
- this.weight = weight;
- }
- }
- public class Node
- {
- private int _value;
- private HashSet<Vector> _children;
- public Node(int v)
- {
- _value = v;
- _children = new HashSet<Vector>();
- }
- public int value()
- {
- return _value;
- }
- public void addChild(Node n , float weight)
- {
- Vector a = new Vector(this, n, weight);
- _children.Add(a);
- }
- public List<Vector> children()
- {
- return _children.ToList();
- }
- }
- public class Graph
- {
- private Dictionary<int, Node> nodes;
- public Graph()
- {
- nodes = new Dictionary<int, Node>();
- }
- public int create()
- {
- Node n = new Node(nodes.Count + 1);
- nodes.Add(n.value(), n);
- return n.value();
- }
- public void connect(int father, int child, float weight)
- {
- Node f, c;
- nodes.TryGetValue(father, out f);
- nodes.TryGetValue(child, out c);
- f.addChild(c, weight);
- c.addChild(f, weight);
- }
- public Graph Kruskal()
- {
- }
Add Comment
Please, Sign In to add comment