1 package org.molwind.graph;
2
3 /*
4 * This file is part of Molwind.
5 *
6 * Molwind is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Molwind is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Molwind. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 import org.molwind.model.Relationship;
21 import edu.uci.ics.jung.graph.util.Pair;
22
23
24
25 /**
26 * DefaultEntityEdge represents an edge in the entity graph.
27 *
28 * @author <a href="mailto:oliver.karch@molwind.org">Oliver Karch</a>
29 * @version 1.0
30 */
31 public class DefaultEntityEdge implements EntityEdge {
32
33 private Relationship relationship;
34 private EntityVertex v1;
35 private EntityVertex v2;
36
37 private int edgeWeight;
38
39 /**
40 * Get the EdgeWeight value.
41 * @return the EdgeWeight value.
42 */
43 public int getEdgeWeight() {
44
45 return edgeWeight;
46
47 }
48
49
50
51 /**
52 * Get the V1 value.
53 * @return the V1 value.
54 */
55 public EntityVertex getV1() {
56 return v1;
57 }
58
59
60 /**
61 * Get the V2 value.
62 * @return the V2 value.
63 */
64 public EntityVertex getV2() {
65 return v2;
66 }
67
68
69
70
71 /**
72 * Set the EdgeWeight value.
73 * @param newEdgeWeight The new EdgeWeight value.
74 */
75 public void setEdgeWeight(int newEdgeWeight) {
76
77 this.edgeWeight = newEdgeWeight;
78 }
79
80 /**
81 * Returns the vertices
82 *
83 * @return
84 * Pair of Vertices
85 */
86 public Pair<EntityVertex> getVerticePair(){
87
88 return new Pair<EntityVertex>(v1,v2);
89
90 }
91
92
93
94
95
96 /**
97 * DefaultEntityEdge constructor.
98 *
99 * @param vertex1
100 * first Vertex
101 * @param vertex2
102 * second Vertex
103 * @param edgeWeight
104 * edgeweight
105 */
106 public DefaultEntityEdge(final EntityVertex vertex1,
107 final EntityVertex vertex2,int edgeWeight) {
108
109 this.edgeWeight=edgeWeight;
110 this.v1=vertex1;
111 this.v2=vertex2;
112 }
113
114
115
116
117 /**
118 * DefaultEntityEdge constructor.
119 *
120 * @param vertex1
121 * first Vertex
122 * @param vertex2
123 * second Vertex
124 */
125 public DefaultEntityEdge(final DefaultEntityVertex vertex1,
126 final DefaultEntityVertex vertex2) {
127
128 this.v1=vertex1;
129 this.v2=vertex2;
130 }
131
132
133 /**
134 *
135 * Checks if the vertex is part of this Edge
136 *
137 * @param
138 * the vertex to checked
139 */
140 public boolean isVertexIncluded(EntityVertex v){
141
142 if((this.v1.getId().equals(v.getId()))
143 ||((this.v2.getId().equals(v.getId()))))
144 return true;
145 else
146 return false;
147 }
148
149
150 /**
151 * Get the Relationship value.
152 *
153 * @return
154 * the Relationship value
155 */
156 public Relationship getRelationship() {
157 return relationship;
158 }
159
160 /**
161 * Set the Relationship value.
162 *
163 * @param newRelation
164 * the new Relationship value
165 */
166 public void setRelationship(final Relationship newRelation) {
167 this.relationship = newRelation;
168 }
169
170 }