001 /*
002 Copyright (c) 2012, Regents of the University of Colorado
003 All rights reserved.
004
005 Redistribution and use in source and binary forms, with or without modification,
006 are permitted provided that the following conditions are met:
007
008 * Redistributions of source code must retain the above copyright notice, this
009 list of conditions and the following disclaimer.
010
011 * Redistributions in binary form must reproduce the above copyright notice,
012 this list of conditions and the following disclaimer in the documentation
013 and/or other materials provided with the distribution.
014
015 * Neither the name of the University of Colorado nor the names of its
016 contributors may be used to endorse or promote products derived from this
017 software without specific prior written permission.
018
019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
022 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
023 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
024 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
025 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
026 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029 */
030
031 package edu.ucdenver.ccp.esm;
032
033 /**
034 * <p>Definition of Edge for dependency graphs</p>
035 *
036 * <p>Edge is then fed into graphs of the JUNG library</p>
037 *
038 * <p>The Edge definition can be modified based on one's own needs</p>
039 *
040 * @author Implemented by Haibin Liu and Tested by Philippe Thomas
041 *
042 */
043 public class Edge {
044 /** governor token */
045 private Vertex gov;
046
047 /** Edge label */
048 private String label;
049
050 /** dependent token */
051 private Vertex dep;
052
053 /**
054 * Construtor to initialize the class field
055 */
056 public Edge (Vertex gov, String label, Vertex dep) {
057 this.gov = gov;
058 this.label = label;
059 this.dep = dep;
060 }
061
062 /**
063 * retrieve dependent node of the edge
064 * @return dependent node
065 */
066 public Vertex getDependent() {
067 return dep;
068 }
069
070 /**
071 * retrieve governor node of the edge
072 * @return governor node
073 */
074 public Vertex getGovernor() {
075 return gov;
076 }
077
078 /**
079 * retrieve edge label
080 * @return edge label
081 */
082 public String getLabel() {
083 return label;
084 }
085
086
087 /**
088 * print edge content
089 */
090 @Override
091 public String toString(){
092 StringBuilder sb = new StringBuilder();
093 sb.append(label);
094 sb.append("(");
095 sb.append(gov.toString());
096 sb.append(", ");
097 sb.append(dep.toString());
098 sb.append(")");
099
100 return sb.toString();
101 }
102 }