Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Repository files navigation

OKAMutableDirectedGraph

image

OKAMutableDirectedGraph is an implementation of a directed graph in Objective-C.

OKAMutableDirectedGraph was developed originally for managing dependencies - but it can be used for path finding, sorting, garbage collection and much more.


Example Usage

 NSString *a = @"a";
 NSString *b = @"b";
 NSString *c = @"c";
 
 OKAMutableDirectedGraph *graph = [[OKAMutableDirectedGraph alloc] init];
 
 for (NSString *job in @[ a, b, c ]) {
   [graph addNode:job];
 }
 
 [graph addEdgeFrom:c to:b];
 [graph addEdgeFrom:b to:a];
 
 NSMutableArray *sorted = [NSMutableArray array];
 
 do {
   
   NSArray *heads = graph.heads;
   
   for (NSString *job in heads) {
     [graph removeNode:job];
     [sorted addObject:job];
   }
   
 } while (graph.heads.count != 0);
 
 (lldb) sorted => @[ c, b, a ]

Documentation & Research

Princeton University - Directed Graphs

Contact

Oliver Atkinson

Licence

OKAMutableDirectedGraph is available under the MIT license. See the LICENSE file for more info.

About

Mutable Directed Graph in Objective C

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.