SkillAgentSearch skills...

OKAMutableDirectedGraph

Mutable Directed Graph in Objective C

Install / Use

/learn @ollieatkinson/OKAMutableDirectedGraph
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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.

Related Skills

View on GitHub
GitHub Stars7
CategoryDevelopment
Updated8y ago
Forks2

Languages

Objective-C

Security Score

70/100

Audited on Jan 18, 2018

No findings