Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Graph types.
Synopsis
- v_is_normal :: [Int] -> Maybe Int
- v_is_normal_err :: [Int] -> Int
- e_eq_undir :: Eq t => (t, t) -> (t, t) -> Bool
- e_sort :: Ord t => (t, t) -> (t, t)
- type Gr t = ([t], [(t, t)])
- gr_map :: (t -> u) -> Gr t -> Gr u
- gr_degree :: Gr t -> (Int, Int)
- gr_relabel :: Eq t => [(t, u)] -> Gr t -> Gr u
- gr_mk_undir :: Ord t => Gr t -> Gr t
- eset_to_gr :: Ord t => [(t, t)] -> Gr t
- gr_sort :: Ord t => Gr t -> Gr t
- gr_complete_graph :: Ord t => [t] -> Gr t
- type G = Gr Int
- g_to_text :: G -> String
- graph_to_g :: Graph -> G
- g_to_graph :: G -> Graph
- gr_unlabel :: Eq t => Gr t -> (G, [(Int, t)])
- gr_to_g :: Eq t => Gr t -> G
- gr_to_graph :: Eq t => Gr t -> (Graph, [(Int, t)])
- g_complete_graph :: Int -> G
- type Edg = ((Int, Int), [(Int, Int)])
- g_to_edg :: G -> Edg
- edg_to_g :: Edg -> G
- edg_parse :: [String] -> Edg
- type Adj t = [(t, [t])]
- adj_to_eset :: Ord t => Adj t -> [(t, t)]
- adj_to_gr :: Ord t => Adj t -> Gr t
- gr_to_adj :: Ord t => (t -> (t, t) -> Maybe t) -> Gr t -> Adj t
- gr_to_adj_dir :: Ord t => Gr t -> Adj t
- gr_to_adj_undir :: Ord t => Gr t -> Adj t
- type Adj_Mtx t = (Int, [[t]])
- edg_to_adj_mtx_undir :: (t, t) -> Edg -> Adj_Mtx t
- g_to_adj_mtx_undir :: (t, t) -> G -> Adj_Mtx t
- adj_mtx_con :: Eq t => (t, t) -> Adj_Mtx t -> Int -> [Int]
- type Lbl_Gr v v_lbl e_lbl = ([(v, v_lbl)], [((v, v), e_lbl)])
- type Lbl v e = Lbl_Gr Int v e
- type Lbl_ v = Lbl v ()
- lbl_degree :: Lbl v e -> (Int, Int)
- lbl_bimap :: (v -> v') -> (e -> e') -> Lbl v e -> Lbl v' e'
- lbl_merge :: Lbl v e -> Lbl v e -> Lbl v e
- lbl_merge_seq :: [Lbl v e] -> Lbl v e
- lbl_canonical :: (Eq v, Ord v) => Lbl v e -> Lbl v e
- lbl_undir :: Lbl v e -> Lbl v e
- lbl_path_graph :: [x] -> Lbl_ x
- lbl_complete_graph :: [x] -> Lbl_ x
- v_label :: v -> Lbl v e -> Int -> v
- v_label_err :: Lbl v e -> Int -> v
- e_label :: e -> Lbl v e -> (Int, Int) -> e
- e_label_err :: Lbl v e -> (Int, Int) -> e
- lbl_gr_to_lbl :: Eq v => Lbl_Gr v v_lbl e_lbl -> Lbl v_lbl e_lbl
- gr_to_lbl :: Eq t => Gr t -> Lbl t (t, t)
- lbl_delete_edge_labels :: Lbl v e -> Lbl_ v
- gr_to_lbl_ :: Eq t => Gr t -> Lbl_ t
- eset_to_lbl :: Ord t => [(t, t)] -> Lbl_ t
- lbl_to_g :: Lbl v e -> G
Vertices
v_is_normal_err :: [Int] -> Int Source #
Edge
e_eq_undir :: Eq t => (t, t) -> (t, t) -> Bool Source #
Un-directed edge equality.
e_eq_undir (0,1) (1,0) == True
(vertices,edges) graph
gr_mk_undir :: Ord t => Gr t -> Gr t Source #
If (i,j) and (j,i) are both in E delete (j,i) where i < j.
eset_to_gr :: Ord t => [(t, t)] -> Gr t Source #
List of E to G, derives V from E.
gr_complete_graph :: Ord t => [t] -> Gr t Source #
Complete k-graph (un-directed) given list of vertices
gr_complete_graph "xyz" == ("xyz",[('x','y'),('x','z'),('y','z')])
Int graph
g_to_text :: G -> String Source #
Simple text representation of G
. Requires (and checks) that vertices are (0 .. |v|-1).
The first line is the number of vertices, following lines are edges.
g_to_graph :: G -> Graph Source #
gr_unlabel :: Eq t => Gr t -> (G, [(Int, t)]) Source #
Unlabel graph, make table.
gr_unlabel ("xyz",[('x','y'),('x','z')]) == (([0,1,2],[(0,1),(0,2)]),[(0,'x'),(1,'y'),(2,'z')])
gr_to_graph :: Eq t => Gr t -> (Graph, [(Int, t)]) Source #
g_to_graph
of gr_unlabel
.
gr = ("abc",[('a','b'),('a','c'),('b','c')]) (g,tbl) = gr_to_graph gr
g_complete_graph :: Int -> G Source #
Complete k-graph (un-directed).
g_complete_graph 3 == ([0,1,2],[(0,1),(0,2),(1,2)])
Edg = edge list (zero-indexed)
Requires (but does not check) that vertices of Edg
are all in (0,|v| - 1).
Adjacencies
edg_to_adj_mtx_undir :: (t, t) -> Edg -> Adj_Mtx t Source #
Edg to Adj_Mtx for un-directed graph.
e = ((4,3),[(0,3),(1,3),(2,3)]) edg_to_adj_mtx_undir (0,1) e == (4,[[0,0,0,1],[0,0,0,1],[0,0,0,1],[1,1,1,0]])
e = ((4,4),[(0,1),(0,3),(1,2),(2,3)]) edg_to_adj_mtx_undir (0,1) e == (4,[[0,1,0,1],[1,0,1,0],[0,1,0,1],[1,0,1,0]])
g_to_adj_mtx_undir :: (t, t) -> G -> Adj_Mtx t Source #
adj_mtx_con :: Eq t => (t, t) -> Adj_Mtx t -> Int -> [Int] Source #
Lookup Adj_Mtx
to find connected vertices.
Labels
type Lbl_Gr v v_lbl e_lbl = ([(v, v_lbl)], [((v, v), e_lbl)]) Source #
Labelled graph, distinct vertex and edge labels.
lbl_bimap :: (v -> v') -> (e -> e') -> Lbl v e -> Lbl v' e' Source #
Apply v at vertex labels and e at edge labels.
lbl_merge :: Lbl v e -> Lbl v e -> Lbl v e Source #
Merge two Lbl
graphs, do not share vertices, vertex indices at g1 are stable.
lbl_canonical :: (Eq v, Ord v) => Lbl v e -> Lbl v e Source #
Re-write graph so vertex indices are (0 .. n-1) and vertex labels are unique.
lbl_path_graph :: [x] -> Lbl_ x Source #
Lbl
path graph.
lbl_complete_graph :: [x] -> Lbl_ x Source #
Lbl
complete graph (undirected, no self-edges)
eset_to_lbl :: Ord t => [(t, t)] -> Lbl_ t Source #
Construct Lbl from set of E, derives V from E.