// IsEdgeValid check whether a edge in or not in the graph
// NOTE: for a undirected graph, it will check both from-to and to-from.
IsEdgeValid check whether a edge in or not in the graph
NOTE: for a undirected graph, it will check both from-to and to-from.
// IsEdgeValid check whether a edge in or not in the graph // NOTE : for a undirected graph it will check both from - to and to - from .
func (g adjacencyListGraph) IsEdgeValid(from, to NodeID) bool {
	if !g.IsNodeValid(from) || !g.IsNodeValid(to) {
		return false
	}
	var fromToValid, toFromValid bool
	for i := 0; i < len(g.adjList[from]); i++ {
		if g.adjList[from][i] == to {
			fromToValid = true
			break
		}
	}
	if g.directed {
		return fromToValid
	}
	for i := 0; i < len(g.adjList[to]); i++ {
		if g.adjList[to][i] == from {
			toFromValid = true
			break
		}
	}
	return fromToValid && toFromValid
}
func ( g adjacencyListGraph ) IsEdgeValid ( from , to NodeID ) bool { if ! g . IsNodeValid ( from ) || ! g . IsNodeValid ( to ) { return false } var fromToValid , toFromValid bool for i := 0 ; i < len ( g . adjList [ from ] ) ; i ++ { if g . adjList [ from ] [ i ] == to { fromToValid = true break } } if g . directed { return fromToValid } for i := 0 ; i < len ( g . adjList [ to ] ) ; i ++ { if g . adjList [ to ] [ i ] == from { toFromValid = true break } } return fromToValid && toFromValid }
IsEdgeValid check whether a edge in or not in the graph
NOTE: for a undirected graph, it will check both from-to and to-from.
IsEdgeValid check whether a edge in or not in the graph NOTE : for a undirected graph it will check both from - to and to - from .
// for undirected graph, check both from-to and to-from