module Data.IntGraph.Undirected (
Node,
NodeSet,
Edge,
IntGraph,
empty,
addNode,
nodes,
removeNode,
addEdge,
edges,
removeEdge,
fromEdges)
where
import qualified Data.IntMap as I
import qualified Data.Set as S
import Data.List (delete)
import Data.IntGraph
import qualified Data.IntGraph.Directed as D
addEdge :: Edge -> IntGraph -> IntGraph
addEdge (u, v) graph = D.addEdge (u, v) $ D.addEdge (v, u) graph
edges :: IntGraph -> [Edge]
edges = D.edges
edges' :: IntGraph -> [Edge]
edges' graph = filter' (edges graph)
where
filter' [] = []
filter' ((u, v):xs) = (u, v) : (filter' $ delete (v, u) xs)
removeEdge :: Edge -> IntGraph -> IntGraph
removeEdge (u, v) graph = D.removeEdge (u, v) $ D.removeEdge (v, u) graph
fromEdges :: [Edge] -> IntGraph
fromEdges graph = foldr addEdge empty graph