Only to be submitted if you did not obtain an exemption for the group project

MatchAnalysis Part 4 — Saving and Loading

In this part you will add functionality to save the PassGraph to a .txt file and to reconstruct it from such a file.


File format

Two sections: [PLAYERS] and [PASSES].

[PLAYERS]
<name>;<number>
<name>;<number>
[PASSES]
<sender_name> -> <receiver_name> : <nr_of_times>

Rules

Example file

Team: Red Devils
[PLAYERS]
Eden Hazard;10
Moussa Dembele;19
Jan Vertonghen;5
Romelu Lukaku;9
[PASSES]
Eden Hazard -> Moussa Dembele : 7
Eden Hazard -> Romelu Lukaku : 2
Jan Vertonghen -> Romelu Lukaku : 1

Tasks (5 points)

Extend your PassGraph class with:

1) Basic operations (1 point)


2) Constructor with path parameter (2 points)

Signature
The constructor accepts an optional argument path (string).

Behavior

Reading requirements


3) save_to_txt(self, path) (1 point)

Save the entire graph in exactly the file format described above.

Requirements


4) Testing (1 point)

Write a test script that: