1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
use ;
/// A simple node type with fixed edge count limits.
///
/// This generic struct allows nodes to have a maximum number of incoming and outgoing edges.
/// The `data` field can store any user-defined data.
///
/// This is a convenience type for common use cases where nodes have fixed edge limits
/// and you don't need complex edge constraint logic.
///
/// # Type Parameters
///
/// * `MAX_IN` - The maximum number of incoming edges
/// * `MAX_OUT` - The maximum number of outgoing edges (defaults to `MAX_IN` for symmetric limits)
/// * `T` - The type of data stored in the node (defaults to `()`)
///
/// # Examples
///
/// Symmetric edge limits (same for incoming and outgoing):
/// ```
/// use bounded_graph::{BoundedGraph, FixedEdgeCount};
///
/// // Node with max 2 edges (both incoming and outgoing)
/// let mut graph = BoundedGraph::<FixedEdgeCount<2, 2>, ()>::new();
/// let n1 = graph.add_node(FixedEdgeCount::empty());
/// let n2 = graph.add_node(FixedEdgeCount::empty());
///
/// assert!(graph.add_edge(n1, n2, ()).is_ok());
/// ```
///
/// Asymmetric edge limits:
/// ```
/// use bounded_graph::{BoundedGraph, FixedEdgeCount};
///
/// // Node with max 2 incoming, 5 outgoing edges
/// let mut graph = BoundedGraph::<FixedEdgeCount<2, 5>, ()>::new();
/// let n1 = graph.add_node(FixedEdgeCount::empty());
/// let n2 = graph.add_node(FixedEdgeCount::empty());
/// let n3 = graph.add_node(FixedEdgeCount::empty());
///
/// // n1 can have up to 5 outgoing edges
/// assert!(graph.add_edge(n1, n2, ()).is_ok());
/// assert!(graph.add_edge(n1, n3, ()).is_ok());
/// ```
///
/// With custom data:
/// ```
/// use bounded_graph::{BoundedGraph, FixedEdgeCount};
///
/// #[derive(Debug)]
/// struct NodeData {
/// name: String,
/// value: i32,
/// }
///
/// let mut graph = BoundedGraph::<FixedEdgeCount<3, 3, NodeData>, ()>::new();
/// let n1 = graph.add_node(FixedEdgeCount::new(NodeData {
/// name: "node1".to_string(),
/// value: 42,
/// }));
///
/// assert_eq!(graph[n1].data.name, "node1");
/// assert_eq!(graph[n1].data.value, 42);
/// ```
/// A simplified node type with symmetric edge count limits.
///
/// This is a convenience type alias for `FixedEdgeCount` where the maximum number
/// of incoming and outgoing edges is the same. Use this for most common cases
/// where nodes have equal limits in both directions.
///
/// # Type Parameters
///
/// * `MAX` - The maximum number of edges (both incoming and outgoing)
/// * `T` - The type of data stored in the node (defaults to `()`)
///
/// # Examples
///
/// Basic usage:
/// ```
/// use bounded_graph::{BoundedGraph, SymmetricFixedEdgeCount};
///
/// // Node with max 3 edges in each direction
/// let mut graph = BoundedGraph::<SymmetricFixedEdgeCount<3>, ()>::new();
/// let n1 = graph.add_node(SymmetricFixedEdgeCount::empty());
/// let n2 = graph.add_node(SymmetricFixedEdgeCount::empty());
///
/// assert!(graph.add_edge(n1, n2, ()).is_ok());
/// ```
///
/// With custom data:
/// ```
/// use bounded_graph::{BoundedGraph, SymmetricFixedEdgeCount};
///
/// let mut graph = BoundedGraph::<SymmetricFixedEdgeCount<3, String>, ()>::new();
/// let n1 = graph.add_node(SymmetricFixedEdgeCount::new("node1".to_string()));
///
/// assert_eq!(graph[n1].data, "node1");
/// ```
pub type SymmetricFixedEdgeCount<const MAX: usize, T = > = ;