Skip to content

Commit 6f8616f

Browse files
committed
Added short documentations at the header of classes.
1 parent 90a021d commit 6f8616f

20 files changed

+177
-84
lines changed

Algorithms/Graphs/BreadthFirstSearcher.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
using System;
1+
/***
2+
* Implements the the Breadth-First Search algorithm.
3+
*
4+
* Provides multiple functions for traversing graphs:
5+
* 1. PrintAll(),
6+
* 2. VisitAll(Action<T> forEachFunc),
7+
* 3. FindFirstMatch(Predicate<T> match).
8+
*
9+
* The VisitAll() applies a function to every graph node. The FindFirstMatch() function searches the graph for a predicate match.
10+
*/
11+
12+
using System;
213
using System.Collections.Generic;
314

415
using DataStructures.Graphs;

Algorithms/Graphs/BreadthFirstShortestPaths.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
using System;
1+
/***
2+
* Computes Shortest-Paths for Unweighted Graphs using the Breadth-First Search algorithm.
3+
* It provides the capability to find shortest-paths from a single-source and multiple-sources, in addition to looking up reachable and unreachable nodes.
4+
*/
5+
6+
using System;
27
using System.Diagnostics;
38
using System.Collections.Generic;
49

Algorithms/Graphs/CyclesDetector.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
using System;
1+
/***
2+
* Detects if a given graph is cyclic. Supports directed and undirected graphs.
3+
*/
4+
5+
using System;
26
using System.Diagnostics;
37
using System.Collections.Generic;
48

Algorithms/Graphs/DepthFirstSearcher.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
using System;
1+
/***
2+
* Implements the Depth-First Search algorithm in two ways: Iterative and Recursive.
3+
*
4+
* Provides multiple functions for traversing graphs:
5+
* 1. PrintAll(),
6+
* 2. VisitAll(Action<T> forEachFunc),
7+
* 3. FindFirstMatch(Predicate<T> match).
8+
*
9+
* The VisitAll() applies a function to every graph node. The FindFirstMatch() function searches the graph for a predicate match.
10+
*/
11+
12+
using System;
213
using System.Collections.Generic;
314

415
using DataStructures.Graphs;

Algorithms/Graphs/DijkstraAllPairsShortestPaths.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
using System;
1+
/***
2+
* Computes Dijktra's shortest paths for all pairs of vertices in a graph.
3+
* This is a wrapper class that applies single-source dijkstra shortest paths (DijkstraShortestPaths<TG, TV>)
4+
* to all vertices of a graph and saves the results in a dictionary index by the vertices.
5+
*/
6+
7+
using System;
28
using System.Diagnostics;
39
using System.Collections.Generic;
410

Algorithms/Graphs/DijkstraShortestPaths.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
using System;
1+
/***
2+
* Computes Dijkstra's Shortest-Paths for Directed Weighted Graphs from a single-source to all destinations.
3+
* This class provides the same API as the BreadthFirstShortestPaths<T>.
4+
*/
5+
6+
using System;
27
using System.Diagnostics;
38
using System.Collections.Generic;
49

Algorithms/Graphs/TopologicalSorter.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
using System;
1+
/***
2+
* Computes one topological sorting of a DAG (Directed Acyclic Graph).
3+
* This class depends on the CyclesDetector static class.
4+
*/
5+
6+
using System;
27
using System.Diagnostics;
38
using System.Collections.Generic;
49

Algorithms/Numeric/CatalanNumbers.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
using System;
1+
/***
2+
* Computes the Catalan Numbers. A dynamic-programming solution.
3+
*
4+
* Wikipedia: https://en.wikipedia.org/wiki/Catalan_number
5+
*/
6+
7+
using System;
28
using System.Diagnostics;
39
using System.Collections.Generic;
410

Algorithms/Strings/Permutations.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
using System;
1+
/***
2+
* Algorithms for computing the list of permutations of a string and checking if two strings are anagrams of each other.
3+
*/
4+
5+
using System;
26
using System.Collections.Generic;
37

4-
namespace Algorithms
8+
namespace Algorithms.Strings
59
{
610
public static class Permutations
711
{

DataStructures/Dictionaries/ChainedHashTable.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
using System;
1+
/***
2+
* Chained Hash Table.
3+
*
4+
* A hash table that implements the Separate-Chaining scheme for resolving keys-collisions. It also implements auto-resizing (expansion and contraction).
5+
*/
6+
7+
using System;
28
using System.Collections.Generic;
39

410
using DataStructures.Common;

DataStructures/Dictionaries/CuckooHashTable.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
using System;
1+
/***
2+
* Cuckoo Hash Table.
3+
*
4+
* A hash table that implements the Cuckoo Hashing algorithm for resolving keys-collisions.
5+
* This is a single-table implementation, the source behind this idea is the work of Mark Allen Weiss, 2014.
6+
*/
7+
8+
using System;
29
using System.Collections.Generic;
310

411
using DataStructures.Common;

DataStructures/Graphs/DirectedDenseGraph.cs

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
using System;
1+
/***
2+
* The Directed Dense Graph Data Structure.
3+
*
4+
* Definition:
5+
* A dense graph is a graph G = (V, E) in which |E| = O(|V|^2).
6+
* A directed graph is a graph where each edge follow one direction only between any two vertices.
7+
*
8+
* An incidence-matrix digraph representation. Follows almost the same implementation
9+
* details of the Undirected version, except for managing the directed edges.
10+
* Implements the IGraph<T> interface.
11+
*/
12+
13+
using System;
214
using System.Collections.Generic;
315

416
using DataStructures.Common;
517
using DataStructures.Lists;
618

719
namespace DataStructures.Graphs
820
{
9-
/// <summary>
10-
/// The Directed Dense Graph Data Structure.
11-
///
12-
/// Definition:
13-
/// A dense graph is a graph G = (V, E) in which |E| = O(|V|^2).
14-
/// A directed graph is a graph where each edge follow one direction only between any two vertices.
15-
///
16-
/// This class represents the graph as an incidence-matrix (two dimensional boolean array).
17-
/// </summary>
1821
public class DirectedDenseGraph<T> : IGraph<T> where T : IComparable<T>
1922
{
2023
/// <summary>

DataStructures/Graphs/DirectedSparseGraph.cs

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
using System;
1+
/***
2+
* The Directed Sparse Graph Data Structure.
3+
*
4+
* Definition:
5+
* A sparse graph is a graph G = (V, E) in which |E| = O(|V|).
6+
* A directed graph is a graph where each edge follow one direction only between any two vertices.
7+
*
8+
* An adjacency-list digraph (directed-graph) representation.
9+
* Implements the IGraph<T> interface.
10+
*/
11+
12+
using System;
213
using System.Collections.Generic;
314

415
using DataStructures.Lists;
516

617
namespace DataStructures.Graphs
718
{
8-
/// <summary>
9-
/// The Directed Sparse Graph Data Structure.
10-
///
11-
/// Definition:
12-
/// A sparse graph is a graph G = (V, E) in which |E| = O(|V|).
13-
/// A directed graph is a graph where each edge follow one direction only between any two vertices.
14-
///
15-
/// This class represents the digraph as an adjacency list (dictionary).
16-
/// </summary>
1719
public class DirectedSparseGraph<T> : IGraph<T> where T : IComparable<T>
1820
{
1921
/// <summary>

DataStructures/Graphs/DirectedWeightedDenseGraph.cs

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
using System;
1+
/***
2+
* The Directed Weighted Dense Graph Data Structure.
3+
*
4+
* Definition:
5+
* A dense graph is a graph G = (V, E) in which |E| = O(|V|^2).
6+
* A directed graph is a graph where each edge follow one direction only between any two vertices.
7+
* A weighted graph is a graph where each edge has a weight (zero weights mean there is no edge).
8+
*
9+
* An adjacency-matrix (two dimensional array of longs) weighted digraph representation.
10+
* Inherits and extends the Directed Dense verion (DirectedDenseGraph<T> class).
11+
* Implements the IWeightedGraph<T> interface.
12+
*/
13+
14+
using System;
215
using System.Collections.Generic;
316

417
using DataStructures.Common;
518
using DataStructures.Lists;
619

720
namespace DataStructures.Graphs
821
{
9-
/// <summary>
10-
/// The Directed Weighted Dense Graph Data Structure.
11-
///
12-
/// Definition:
13-
/// A dense graph is a graph G = (V, E) in which |E| = O(|V|^2).
14-
/// A directed graph is a graph where each edge follow one direction only between any two vertices.
15-
/// A weighted graph is a graph where each edge has a weight (zero weights mean there is no edge).
22+
1623
///
1724
/// This class represents the graph as an adjacency-matrix (two dimensional integer array).
1825
/// </summary>

DataStructures/Graphs/DirectedWeightedSparseGraph.cs

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
using System;
1+
/***
2+
* The Directed Sparse Graph Data Structure.
3+
*
4+
* Definition:
5+
* A sparse graph is a graph G = (V, E) in which |E| = O(|V|).
6+
* A directed graph is a graph where each edge follow one direction only between any two vertices.
7+
* A weighted graph is a graph where each edge has a weight (zero weights mean there is no edge).
8+
*
9+
* An adjacency-list weighted digraph representation. Shares a good deal of implemention details
10+
* with the Directed Sparse version (DirectedSparseGraph<T>). Edges are instances of WeightedEdge<T> class.
11+
* Implements both interfaces: IGraph<T> and IWeightedGraph<T>.
12+
*/
13+
14+
using System;
215
using System.Diagnostics;
316
using System.Collections.Generic;
417

@@ -7,16 +20,6 @@
720

821
namespace DataStructures.Graphs
922
{
10-
/// <summary>
11-
/// The Directed Sparse Graph Data Structure.
12-
///
13-
/// Definition:
14-
/// A sparse graph is a graph G = (V, E) in which |E| = O(|V|).
15-
/// A directed graph is a graph where each edge follow one direction only between any two vertices.
16-
/// A weighted graph is a graph where each edge has a weight (zero weights mean there is no edge).
17-
///
18-
/// This class represents the digraph as an adjacency-list (dictionary).
19-
/// </summary>
2023
public class DirectedWeightedSparseGraph<T> : IGraph<T>, IWeightedGraph<T> where T : IComparable<T>
2124
{
2225
/// <summary>

DataStructures/Graphs/UndirectedDenseGraph.cs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
using System;
1+
/***
2+
* The Dense Graph Data Structure.
3+
*
4+
* Definition: A dense graph is a graph G = (V, E) in which |E| = O(|V|^2).
5+
*
6+
* An incidence-matrix (two dimensional boolean array) graph representation.
7+
* This class implements the IGraph<T> interface.
8+
*/
9+
10+
using System;
211
using System.Collections.Generic;
312

413
using DataStructures.Common;
514
using DataStructures.Lists;
615

716
namespace DataStructures.Graphs
817
{
9-
/// <summary>
10-
/// The Dense Graph Data Structure.
11-
///
12-
/// Definition:
13-
/// A dense graph is a graph G = (V, E) in which |E| = O(|V|^2).
14-
///
15-
/// This class represents the graph as an incidence-matrix (two dimensional boolean array).
16-
/// </summary>
1718
public class UndirectedDenseGraph<T> : IGraph<T> where T : IComparable<T>
1819
{
1920
/// <summary>

DataStructures/Graphs/UndirectedSparseGraph.cs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
using System;
1+
/***
2+
* The Sparse Graph Data Structure.
3+
* Definition: A sparse graph is a graph G = (V, E) in which |E| = O(|V|).
4+
*
5+
* An adjacency-list graph representation. Implemented using a Dictionary. The nodes are inserted as keys,
6+
* and the neighbors of every node are implemented as a doubly-linked list of nodes.
7+
* This class implements the IGraph<T> interface.
8+
*/
9+
10+
using System;
211
using System.Collections.Generic;
312

413
using DataStructures.Lists;
514

615
namespace DataStructures.Graphs
716
{
8-
/// <summary>
9-
/// The Sparse Graph Data Structure.
10-
///
11-
/// Definition:
12-
/// A sparse graph is a graph G = (V, E) in which |E| = O(|V|).
13-
///
14-
/// This class represents the graph as an adjacency list (dictionary).
15-
/// </summary>
1617
public class UndirectedSparseGraph<T> : IGraph<T> where T : IComparable<T>
1718
{
1819
/// <summary>

DataStructures/Hashing/PrimeHashingFamily.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
using System;
1+
/***
2+
* Prime-Hashing Functions Family.
3+
*
4+
* Implements a simple family of hash functions using primes.
5+
* The functions are initialized by randomly selecting primes.
6+
* Supports re-generation of functions.
7+
*/
8+
9+
using System;
210

311
using DataStructures.Common;
412
using DataStructures.Lists;

DataStructures/Hashing/UniversalHashingFamily.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
using System;
1+
/***
2+
* Universal-Hashing Functions Family.
3+
*
4+
* Implements a family class of simple universal-hashing functions.
5+
* Supports re-generation of functions.
6+
* It depends on the Common/PrimesList helper class.
7+
*
8+
* This class is used in the Cuckoo Hash Table implementation.
9+
*/
10+
11+
using System;
212

313
using DataStructures.Common;
414
using DataStructures.Lists;

MainProgram/Program.cs

+1-13
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,7 @@ public class Program
1212
{
1313
public static void Main(string[] args)
1414
{
15-
string input = "2-4+5*6-1";
16-
17-
var result = input.Split(new char[] { '-', '+', '*' }).ToList()
18-
.Select<string, int>(item => Convert.ToInt32(item))
19-
.ToList<int>();
20-
21-
var ops = new List<char>();
22-
23-
for(int i = 0; i < input.Length; i++) {
24-
if(input[i] == '+' || input[i] == '-' || input[i] == '*') {
25-
ops.Add (input [i]);
26-
}
27-
}
15+
2816
}
2917
}
3018
}

0 commit comments

Comments
 (0)