// DeleteEdge delete en edge between FromNode and ToNode from the graph.
// make sure both FromNode and ToNode are already inside the graph.
// NOTE: for a undirected graph, this func will delete both from-to and to-from from the graph.
DeleteEdge delete en edge between FromNode and ToNode from the graph.
make sure both FromNode and ToNode are already inside the graph.
NOTE: for a undirected graph, this func will delete both from-to and to-from from the graph.
// DeleteEdge delete en edge between FromNode and ToNode from the graph . // make sure both FromNode and ToNode are already inside the graph . // NOTE : for a undirected graph this func will delete both from - to and to - from from the graph .
func (g adjacencyListGraph) DeleteEdge(from, to NodeID) error {
	if !g.IsNodeValid(from) || !g.IsNodeValid(to) {
		return fmt.Errorf("From node %v or To node %v invalid", from, to)
	}
	for i := 0; i < len(g.adjList[from]); i++ {
		if g.adjList[from][i] == to {
			g.adjList[from] = append(g.adjList[from][0:i], g.adjList[from][i+1:]...)
			break
		}
	}
	if !g.directed {
		for i := 0; i < len(g.adjList[to]); i++ {
			if g.adjList[to][i] == from {
				g.adjList[to] = append(g.adjList[to][0:i], g.adjList[to][i+1:]...)
				break
			}
		}
	}
	return nil
}
func ( g adjacencyListGraph ) DeleteEdge ( from , to NodeID ) error { if ! g . IsNodeValid ( from ) || ! g . IsNodeValid ( to ) { return fmt . Errorf ( " " , from , to ) } for i := 0 ; i < len ( g . adjList [ from ] ) ; i ++ { if g . adjList [ from ] [ i ] == to { g . adjList [ from ] = append ( g . adjList [ from ] [ 0 : i ] , g . adjList [ from ] [ i + 1 : ] ... ) break } } if ! g . directed { for i := 0 ; i < len ( g . adjList [ to ] ) ; i ++ { if g . adjList [ to ] [ i ] == from { g . adjList [ to ] = append ( g . adjList [ to ] [ 0 : i ] , g . adjList [ to ] [ i + 1 : ] ... ) break } } } return nil }
DeleteEdge delete en edge between FromNode and ToNode from the graph.
DeleteEdge delete en edge between FromNode and ToNode from the graph .
// for undirected graph, delete both from-to and to-from from the graph