Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface IGraphNode
- {
- IGraphNode From { get; set; }
- IGraphNode To { get; set; }
- }
- IGraphNode A = new GraphNode();
- IGraphNode B = new GraphNode();
- A.To = B;
- IGraphNode From
- {
- get { return from; }
- set
- {
- from = value;
- if (value.To != this) {
- value.To = this;
- }
- }
- }
- IGraphNode To
- {
- get { return to; }
- set
- {
- to = value;
- if (value.From != this) {
- value.From = this;
- }
- }
- }
- A.To = B;
- B.From = A;
- IGraphNode A = new GraphNode();
- IGraphNode B = new GraphNode();
- IGraphNode C = new GraphNode();
- A.To = B;
- C.To = B;
- // what should B.From return?
- IGraphNode A = new GraphNode();
- IGraphNode B = new GraphNode();
- A.To = B;
- A = null; // should the reference from B keep the object
- // that A used to reference alive?
- void ConnectNodes(IGraphNode a, IGraphNode b)
- {
- a.to = b;
- b.from = a;
- }
- void ConnectNodes(IGraphNode b)
- {
- this.to = b;
- b.from = this;
- }
Add Comment
Please, Sign In to add comment