1 /*
2 Graph.h
3 graph_cmd
4
5 Created by Jamie Griffin on Mon Mar 01 2004.
6
7 This class represents a graph. Graphs contain an array of verticies and
8 an array of properly 3-colored graphs.
9
10 NSCopying and NSCoding are implemented so that copies can be made with
11 standard method calls and graphs can be saved to files using an encoder.
12
13
14 */
15
16 //Version 1.0b6
17
18 #import <Foundation/Foundation.h>
19 #import "Vertex.h"
20
21
22 @interface Graph : NSObject <NSCoding, NSCopying>
23 {
24
25 NSMutableArray *verticies; //an array of Vertex
26 NSMutableArray *threeColorings; //an array of Graphs
27
28 }
29
30 //init and copy methods
31 -(id)initWithGraph:(Graph *)graph copyItems:(BOOL)copy;
32 -(id)initWithGraphNoColors:(Graph *)graph copyItems:(BOOL)copy; //does not copy threeColorings
33 +(Graph *)graphWithGraph:(Graph *)graph copyItems:(BOOL)copy;
34 +(Graph *)loadGraphFromTextFile:(NSString *)file;
35
36
37
38 //accessors
39 -(NSMutableArray *)graphAsArray; //returns the vertices as an NSArray
40 -(NSMutableArray *)threeColorings; //returns the threeColorings array
41 -(NSString *)graphAsString; //gives a string representation of a graph
42 -(id)vertexWithNumber:(int)thisNumber; //get a specific vertex based on number, not array position
43 -(Vertex *)vertexWithPosition:(int)thisPosition; //gets a vertex based on array position
44 -(unsigned)count; //the size of the graph
45
46 //mutators
47 -(void)addVertex:(Vertex *)thisVertex withCopy:(BOOL)copy; //add a vertex, either copying or not
48 -(NSArray *)breakGraphInParts:(int)numParts; //gives an array of subgraphs
49 -(BOOL)isThisGraphProperlyThreeColored; //checks to see if the current coloring is correct
50 -(NSMutableArray *)getThreeColorings; //calls the recursive method and returns results
51 -(void)recursiveCheck:(Graph *)remainingVerticies; //the recursive method to color the graph
52 -(void)combineThisWithGraph:(Graph *)otherGraph; //recombines this colored graph with another
53
54 @end
syntax highlighted by Code2HTML, v. 0.9.1