| 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 Dec 11, 2003 | |
| 12 | */ | |
| 13 | package edu.uci.ics.jung.graph.impl; | |
| 14 | ||
| 15 | import java.util.Set; | |
| 16 | ||
| 17 | import edu.uci.ics.jung.graph.*; | |
| 18 | ||
| 19 | /** | |
| 20 | * A HyperEdge has zero or more HyperVertices attached to it; | |
| 21 | * this implements that as part of an underlying HyperGraph. | |
| 22 | * | |
| 23 | * @author danyelf | |
| 24 | * @deprecated As of version 1.7, replaced by native implementations of <code>Hyperedge</code>. | |
| 25 | * @see SetHyperedge | |
| 26 | * @see ListHyperedge | |
| 27 | */ | |
| 28 | public class HyperedgeBPG extends AbstractHyperUnitBPG implements Hyperedge{ | |
| 29 | ||
| 30 | 14 | public HyperedgeBPG() { |
| 31 | 14 | } |
| 32 | ||
| 33 | HyperedgeBPG( BipartiteVertex bpv, HypergraphBPG hypergraphBPG ) { | |
| 34 | 2 | super( bpv, hypergraphBPG ); |
| 35 | 2 | } |
| 36 | ||
| 37 | public Set getIncidentElements() | |
| 38 | { | |
| 39 | 0 | return getIncidentVertices(); |
| 40 | } | |
| 41 | ||
| 42 | /** | |
| 43 | * @see edu.uci.ics.jung.graph.ArchetypeEdge#getIncidentVertices() | |
| 44 | */ | |
| 45 | public Set getIncidentVertices() { | |
| 46 | 0 | return graph.translateUnderlyingVertices(vertex.getNeighbors()); |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * @see edu.uci.ics.jung.graph.ArchetypeEdge#getEqualEdge(edu.uci.ics.jung.graph.ArchetypeGraph) | |
| 51 | */ | |
| 52 | public ArchetypeEdge getEqualEdge(ArchetypeGraph g) { | |
| 53 | 2 | HypergraphBPG bpg = (HypergraphBPG) g; |
| 54 | // check if that graph's underlying vertex is the same as this one's. | |
| 55 | 2 | return bpg.getEdgeCorrespondingTo( underlying_vertex() ); |
| 56 | } | |
| 57 | ||
| 58 | /** | |
| 59 | * @deprecated As of version 1.4, renamed to getEqualEdge(g). | |
| 60 | */ | |
| 61 | public ArchetypeEdge getEquivalentEdge(ArchetypeGraph g) | |
| 62 | { | |
| 63 | 0 | return getEqualEdge(g); |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * @see edu.uci.ics.jung.graph.ArchetypeEdge#numVertices() | |
| 68 | */ | |
| 69 | public int numVertices() { | |
| 70 | 0 | return vertex.degree(); |
| 71 | } | |
| 72 | ||
| 73 | /** | |
| 74 | * @see edu.uci.ics.jung.graph.ArchetypeEdge#isIncident(edu.uci.ics.jung.graph.ArchetypeVertex) | |
| 75 | */ | |
| 76 | public boolean isIncident(ArchetypeVertex v) { | |
| 77 | 0 | HypervertexBPG hv = (HypervertexBPG) v; |
| 78 | 0 | return vertex.isNeighborOf(hv.underlying_vertex()); |
| 79 | } | |
| 80 | ||
| 81 | /** | |
| 82 | * @see edu.uci.ics.jung.graph.ArchetypeEdge#copy(edu.uci.ics.jung.graph.ArchetypeGraph) | |
| 83 | */ | |
| 84 | public ArchetypeEdge copy(ArchetypeGraph g) { | |
| 85 | 0 | HypergraphBPG hg = (HypergraphBPG) g; |
| 86 | 0 | HyperedgeBPG he = new HyperedgeBPG(); |
| 87 | 0 | hg.addEdge( he ); |
| 88 | 0 | he.importUserData(this); |
| 89 | 0 | return he; |
| 90 | } | |
| 91 | ||
| 92 | /** | |
| 93 | * Registers an additional vertex <code>hv3_x</code> onto this Edge. | |
| 94 | */ | |
| 95 | public boolean connectVertex(Hypervertex hv3_x) | |
| 96 | { | |
| 97 | 22 | HypervertexBPG hv3 = (HypervertexBPG) hv3_x; |
| 98 | 22 | BipartiteGraph bpg = (BipartiteGraph) hv3.underlying_vertex().getGraph(); |
| 99 | 22 | BipartiteVertex v1 = hv3.underlying_vertex(); |
| 100 | 22 | BipartiteVertex v2 = underlying_vertex(); |
| 101 | ||
| 102 | 22 | if (v1.isNeighborOf(v2)) |
| 103 | 0 | return false; |
| 104 | ||
| 105 | 22 | bpg.addBipartiteEdge(new BipartiteEdge(v1, v2)); |
| 106 | ||
| 107 | 22 | return true; |
| 108 | } | |
| 109 | ||
| 110 | public boolean disconnectVertex(Hypervertex v) | |
| 111 | { | |
| 112 | 0 | HypervertexBPG hv3 = (HypervertexBPG)v; |
| 113 | 0 | BipartiteGraph bpg = (BipartiteGraph) hv3.underlying_vertex().getGraph(); |
| 114 | 0 | BipartiteVertex v1 = hv3.underlying_vertex(); |
| 115 | 0 | BipartiteVertex v2 = underlying_vertex(); |
| 116 | 0 | Edge e = v1.findEdge(v2); |
| 117 | 0 | if (e != null) |
| 118 | { | |
| 119 | 0 | bpg.removeEdge(e); |
| 120 | 0 | return true; |
| 121 | } | |
| 122 | 0 | return false; |
| 123 | } | |
| 124 | ||
| 125 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |