All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.deeplearning4j.graph.api.Edge Maven / Gradle / Ivy

There is a newer version: 1.0.0-M2.1
Show newest version
package org.deeplearning4j.graph.api;

import lombok.Data;

/** Edge in a graph. May be a directed or undirected edge.
* Parameterized, and may store a value/object associated with the edge */ @Data public class Edge { private final int from; private final int to; private final T value; private final boolean directed; public Edge(int from, int to, T value, boolean directed ){ this.from = from; this.to = to; this.value = value; this.directed = directed; } @Override public String toString() { return "edge(" + (directed ? "directed" : "undirected") + "," + from+ (directed ? "->" : "--") + to + "," + (value!=null ? value : "") + ")"; } @Override public boolean equals(Object o){ if(!(o instanceof Edge)) return false; Edge e = (Edge)o; if(directed != e.directed) return false; if(directed){ if(from != e.from) return false; if(to != e.to) return false; } else { if(from == e.from){ if(to != e.to) return false; } else { if(from != e.to) return false; if(to != e.from) return false; } } if((value != null && e.value == null) || (value == null && e.value != null)) return false; return value == null || value.equals(e.value); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy