This program is created to work with graph data structures.
You can look which themes I used in this project.
No libraries used.
- Clone the repository:
git clone https://github.com/kreslavskiy/graphs
- Run the program:
node src/commands.js
Type 'help' to see what which command does.
- To create a new graph just type 'new', then enter name of the graph and key field
- To add a new vertex to your graph use command 'add', then you'll have to enter type of the vertex, which you choose by yourself, and data that the vertex will contain.
Warning: don’t use quotes, otherwise vertex won't be added to the graph.
- Use 'link' or 'dlink' commands to create a relation between vertices. 'link' creates undirected link and 'dlink' is for directed links. Also you'll have to enter name of the link for both commands.
Note: you can link multiple vertices at once, it'll work by many-to-many principle
- Now, when you have a graph of 2 vertices, you may want to see it. Use command 'show' for it!
- If you created many vertices and you want to see concrete ones, you can use command 'select', and select vertices by data:
or by links:
or by both:
- To modify vertex data, you should use command 'modify', choose the vertex you want to change and enter new data. All new data will overwrite on existing one.
Note: you can change even key field of data!
- If you want to delete relation between vertices, use 'unlink' command.
Note: it works by one-to-many principle
- Now we can delete usless vertex by using command 'delete'
- You also can save your graph, type 'save', enter file name and it'll be saved in .json format.
- After saving, you can also open your graph in my program. Use command 'import' and enter file name.
- If you created a graph and you want to concatinate it with another one, you can use command 'join', it'll upload data from entered file and unite these 2 graphs.
Warning: if graphs have different key fields, they won't merge
- To delete all vertices at once use command 'clear', but you need to enter the name of graph to chack if you are sure.
- To quit program use command 'exit'. IF you have unsaved data, it'll ask you if you want to save it. Type 'y' if you do and 'n' if don’t.
To test the program, type node tests/tests.js
, it expects everething to execute successfully.
Then type node tests/testsErrors.js
, it expects everything to throw errors.