Skip to content

Commit 73154f2

Browse files
committed
Format and document
1 parent a49ebd3 commit 73154f2

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

lib/graph/graph.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import 'vertex.dart';
22

33
/// A Graph Type
44
class Graph<T> {
5-
/// Vertices of this graph
65
Set<Vertex<T>> _vertices;
6+
7+
/// Vertices of this graph
78
List<Vertex<T>> get vertices => List<Vertex<T>>.unmodifiable(_vertices);
89

910
/// Settings for this graph

lib/graph/vertex.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ class Vertex<T> {
3333
this.value = value ?? key;
3434
}
3535

36+
/// Lock [this] vertex, cannot modify after it is locked
3637
void lock() => _isLocked = true;
38+
39+
/// Unlock [this] vertex, can modify after it is unlock
3740
void unlock() => _isLocked = false;
3841

3942
/// Adds a connection with [Vertex] `dst` and with `weight`
4043
bool addConnection(Vertex dst, [num weight = 1]) {
41-
if (_isLocked || dst._isLocked)
44+
if (_isLocked || dst._isLocked) {
4245
throw UnsupportedError('Cannot add to a locked vertex');
46+
}
4347
if (_outgoingConnections.containsKey(dst)) {
4448
return false;
4549
}
@@ -51,8 +55,9 @@ class Vertex<T> {
5155
/// Removes a connection with `other` with `weight`. `false` for non-existent
5256
/// connection.
5357
bool removeConnection(Vertex other, [num weight = 1]) {
54-
if (_isLocked || other._isLocked)
58+
if (_isLocked || other._isLocked) {
5559
throw UnsupportedError('Cannot remove from a locked vertex');
60+
}
5661
var outgoingRemoved = _outgoingConnections.remove(other) != null;
5762
var incomingRemoved = other._incomingVertices.remove(this);
5863

test/graph/vertex_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void main() {
131131
});
132132

133133
test('Get out degree for vertex', () {
134-
Vertex c = Vertex('c');
134+
var c = Vertex('c');
135135
c.unlock();
136136
expect(root.outDegree, equals(0));
137137
connectedVertex.addConnection(c);

0 commit comments

Comments
 (0)