Load the graph skeleton from a text file located at *path*. Text file must be a plaintext .txt file with a JSON-style representation of a dict. Dict must contain the top-level keys "V" and "E" with the following formats:: { 'V': ['<vertex_name
(self, path)
| 45 | '''(Inherited from dictionary) A variable that stores a key-indexable dictionary once it is loaded from a file.''' |
| 46 | |
| 47 | def load(self, path): |
| 48 | ''' |
| 49 | Load the graph skeleton from a text file located at *path*. |
| 50 | |
| 51 | Text file must be a plaintext .txt file with a JSON-style representation of a dict. Dict must contain the top-level keys "V" and "E" with the following formats:: |
| 52 | |
| 53 | { |
| 54 | 'V': ['<vertex_name_1>', ... , '<vertex_name_n'], |
| 55 | 'E': [['vertex_of_origin', 'vertex_of_destination'], ... ] |
| 56 | } |
| 57 | |
| 58 | Arguments: |
| 59 | 1. *path* -- The path to the file containing input data (e.g., "mydictionary.txt"). |
| 60 | |
| 61 | Attributes modified: |
| 62 | 1. *V* -- The set of vertices. |
| 63 | 2. *E* -- The set of edges. |
| 64 | |
| 65 | ''' |
| 66 | self.dictload(path) |
| 67 | self.V = self.alldata["V"] |
| 68 | self.E = self.alldata["E"] |
| 69 | |
| 70 | # free unused memory |
| 71 | del self.alldata |
| 72 | |
| 73 | def getparents(self, vertex): |
| 74 | ''' |