// AddEdge add en edge between FromNode and ToNode.
// make sure both FromNode and ToNode are already inside the graph.
// NOTE: for a undirected graph, this func will add both from-to and to-from into the graph.
AddEdge add en edge between FromNode and ToNode.
make sure both FromNode and ToNode are already inside the graph.
NOTE: for a undirected graph, this func will add both from-to and to-from into the graph.
// AddEdge add en edge between FromNode and ToNode . // make sure both FromNode and ToNode are already inside the graph . // NOTE : for a undirected graph this func will add both from - to and to - from into the graph .
func (g adjacencyMatrixGraph) AddEdge(from, to NodeID) error {
	if !g.IsNodeValid(from) || !g.IsNodeValid(to) {
		return fmt.Errorf("From node %v or To node %v invalid", from, to)
	}
	g.adjMatrix[from][to] = true
	if !g.directed {
		g.adjMatrix[to][from] = true
	}
	return nil
}
func ( g adjacencyMatrixGraph ) AddEdge ( from , to NodeID ) error { if ! g . IsNodeValid ( from ) || ! g . IsNodeValid ( to ) { return fmt . Errorf ( " " , from , to ) } g . adjMatrix [ from ] [ to ] = true if ! g . directed { g . adjMatrix [ to ] [ from ] = true } return nil }
AddEdge add en edge between FromNode and ToNode.
AddEdge add en edge between FromNode and ToNode .
// for undirected graph, add both from-to and to-from into the graph