1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
18 using System
.Collections
;
19 using System
.Collections
.Generic
;
22 public class GraphNode
: IVertex
25 public class GraphNode
: MarshalByRefObject
, IVertex
28 private List
<GraphNode
> incoming
;
29 private List
<GraphNode
> outgoing
;
36 // /// Kind of copy constructor
38 // /// <param name="copy"></param>
39 // public GraphNode(GraphNode copy)
41 // incoming = new ArrayList(Incoming);
42 // outgoing = new ArrayList(Outgoing);
45 #region IVertex Members
47 public IVertex
[] Adjacencies
49 get { return Dependents; }
54 public void AddDependent(GraphNode node
)
57 node
.Incoming
.Add(this);
60 private List
<GraphNode
> Incoming
64 if (incoming
== null) incoming
= new List
<GraphNode
>();
69 private List
<GraphNode
> Outgoing
73 if (outgoing
== null) outgoing
= new List
<GraphNode
>();
79 /// The nodes that dependes on this node
81 public GraphNode
[] Dependers
85 if (incoming
== null) return new GraphNode
[0];
86 return incoming
.ToArray();
91 /// The nodes that this node depends
93 public GraphNode
[] Dependents
97 if (outgoing
== null) return new GraphNode
[0];
98 return outgoing
.ToArray();
102 public void RemoveDepender(GraphNode depender
)
104 Incoming
.Remove(depender
);
105 depender
.RemoveDependent(this);
108 private void RemoveDependent(GraphNode graphNode
)
110 Outgoing
.Remove(graphNode
);