# Coverage details for edu.uci.ics.jung.graph.impl.BipartiteEdge

Line | Hits | Source
--- | --- | ---
1 |  | `/*`
2 |  | `* Copyright (c) 2003, the JUNG Project and the Regents of the University`
3 |  | `* of California`
4 |  | `* All rights reserved.`
5 |  | `*`
6 |  | `* This software is open-source under the BSD license; see either`
7 |  | `* "license.txt" or`
8 |  | `* http://jung.sourceforge.net/license.txt for a description.`
9 |  | `*/`
10 |  | `/*`
11 |  | `* Created on Aug 15, 2003`
12 |  | `*`
13 |  | `*/`
14 |  | `package edu.uci.ics.jung.graph.impl;`
15 |  | ``
16 |  | `import edu.uci.ics.jung.exceptions.FatalException;`
17 |  | `import edu.uci.ics.jung.graph.ArchetypeEdge;`
18 |  | `import edu.uci.ics.jung.graph.ArchetypeGraph;`
19 |  | `import edu.uci.ics.jung.utils.Pair;`
20 |  | ``
21 |  | `/**`
22 |  | `* A simple extension of the UndirectedSparseEdge, except`
23 |  | `* with careful bounds checking. The constructor throws`
24 |  | `* a FatalException if its vertices are not in two classes`
25 |  | `* of a BipartiteGraph. (In fact, the Vertices must come in`
26 |  | `* the order CLASSA, CLASSB).`
27 |  | `*`
28 |  | `* @author danyelf`
29 |  | `*/`
30 |  | `public class BipartiteEdge extends UndirectedSparseEdge {`
31 |  | ``
32 |  | `/**`
33 |  | `* The BipartiteEdge constructor.`
34 |  | `* @param a a Vertex from a BipartiteGraph in CLASSA`
35 |  | `* @param b a Vertex from the same BipartiteGraph in CLASSB`
36 |  | `*/`
37 |  | `public BipartiteEdge(BipartiteVertex a, BipartiteVertex b) {`
38 | 64 | `super(a, b);`
39 | 64 | `BipartiteGraph g = (BipartiteGraph) a.getGraph();`
40 |  | ``
41 | 64 | `boolean aInA = g.getAllVertices(BipartiteGraph.CLASSA).contains(a);`
42 | 64 | `boolean bInB = g.getAllVertices(BipartiteGraph.CLASSB).contains(b);`
43 |  | ``
44 | 64 | `if (!(aInA && bInB))`
45 | 2 | `throw new FatalException("Tried to create edge that isn't bipartite!");`
46 | 62 | `}`
47 |  | ``
48 |  | `public ArchetypeEdge copy(ArchetypeGraph newGraph) {`
49 | 13 | `if (newGraph == this.getGraph())`
50 | 0 | `throw new IllegalArgumentException(`
51 |  | `"Source and destination " + "graphs must be different");`
52 |  | ``
53 | 13 | `Pair ends = getEndpoints();`
54 |  | ``
55 | 13 | `BipartiteVertex eFrom =`
56 |  | `(BipartiteVertex) ends.getFirst();`
57 | 13 | `BipartiteVertex eTo =`
58 |  | `(BipartiteVertex) ends.getSecond();`
59 |  | ``
60 | 13 | `BipartiteVertex from = (BipartiteVertex) eFrom.getEqualVertex(newGraph);`
61 | 13 | `BipartiteVertex to = (BipartiteVertex) eTo.getEqualVertex(newGraph);`
62 |  | ``
63 | 13 | `if (from == null || to == null)`
64 | 0 | `throw new IllegalArgumentException(`
65 |  | `"Cannot create edge: source edge's incident "`
66 |  | `+ "vertices have no equivalents in target graph");`
67 |  | ``
68 | 13 | `if (from.getGraph() != newGraph) {`
69 | 0 | `throw new FatalException("Unexpected error: 'from' vertex is not in target graph");`
70 |  | `}`
71 | 13 | `if (to.getGraph() != newGraph) {`
72 | 0 | `throw new FatalException("Unexpected error: 'to' vertex is not in target graph");`
73 |  | `}`
74 | 13 | `if (eFrom.getGraph() == from.getGraph()) {`
75 | 0 | `throw new FatalException("Unexpected error: 'from' and 'to' vertices are not in same graph");`
76 |  | `}`
77 |  | ``
78 |  | `BipartiteEdge e;`
79 |  | `try {`
80 | 13 | `e = (BipartiteEdge) this.clone();`
81 | 0 | `} catch (CloneNotSupportedException cnse) {`
82 | 0 | `throw new FatalException("Can't copy edge", cnse);`
83 | 13 | `}`
84 |  | ``
85 | 13 | `e.m_Graph = null;`
86 | 13 | `e.mFrom = from;`
87 | 13 | `e.mTo = to;`
88 | 13 | `((BipartiteGraph) newGraph).addBipartiteEdge(e);`
89 | 13 | `e.importUserData(this);`
90 | 13 | `return e;`
91 |  | ``
92 |  | `}`
93 |  | ``
94 |  | `}`

this report was generated by version 1.0.5 of jcoverage. visit www.jcoverage.com for updates. | copyright © 2003, jcoverage ltd. all rights reserved. Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.