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
;
21 public class GraphNode
: MarshalByRefObject
, IVertex
23 private ArrayList incoming
;
24 private ArrayList outgoing
;
31 // /// Kind of copy constructor
33 // /// <param name="copy"></param>
34 // public GraphNode(GraphNode copy)
36 // incoming = new ArrayList(Incoming);
37 // outgoing = new ArrayList(Outgoing);
40 #region IVertex Members
42 public IVertex
[] Adjacencies
44 get { return Dependents; }
49 public void AddDependent(GraphNode node
)
52 node
.Incoming
.Add(this);
55 private ArrayList Incoming
59 if (incoming
== null) incoming
= new ArrayList();
64 private ArrayList Outgoing
68 if (outgoing
== null) outgoing
= new ArrayList();
74 /// The nodes that dependes on this node
76 public GraphNode
[] Dependers
80 if (incoming
== null) return new GraphNode
[0];
81 return (GraphNode
[]) incoming
.ToArray(typeof(GraphNode
));
86 /// The nodes that this node depends
88 public GraphNode
[] Dependents
92 if (outgoing
== null) return new GraphNode
[0];
93 return (GraphNode
[]) outgoing
.ToArray(typeof(GraphNode
));
97 public void RemoveDepender(GraphNode depender
)
99 Incoming
.Remove(depender
);
100 depender
.RemoveDependent(this);
103 private void RemoveDependent(GraphNode graphNode
)
105 Outgoing
.Remove(graphNode
);