/* * Copyright 2011 Steven Gribble * * This file is the solution to an exercise problem posed during * one of the UW CSE 333 lectures (333exercises). * * 333exercises is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 333exercises is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with 333exercises. If not, see . */ #ifndef _GRAPHOPS_H_ #define _GRAPHOPS_H_ #include "ll.h" // We represent a collaboration graph as a linked list of scientists. // For each scientist in the list, we store a Collab; a Collab // contains the string name of the scientist, as well a linked list // of collaborators. (Each node in the linked list ofcollaborators // contains the string name of the collaborators.) // // Pictorially... // // A --> B --> C --> D // | | | | // B A A A // | | | // C D C // | // D typedef struct CollabSt { char *scientist; Node *collaborators; } Collab; // This is the main linked list of scientist Collab structs. extern Node *collabgraph; // Loops through the collaboration graph, looking for the // scientist with the given name. If found, returns the // head of the linked list of collaborators. If not found, // returns NULL. Node *GetCollaboratorList(char *scientist); // Tests to see whether the given collaborator is already // listed in the collaborator list for scientist "scientist". // If so, returns 1. If either the scientist couldn't be // found, or the collaborator isn't listed for the scientist, // returns 0. int TestIfCollaborator(char *scientist, char *collaborator); // Adds the (scientist --> collaborator) pair to the // collaboration graph, making a copy of both strings. void AddCollaboration(char *scientist, char *collaborator); #endif // _READLINE_FROM_FILE_H_