Skip to content

kreslavskiy/graphs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graphs

This program is created to work with graph data structures.

You can look which themes I used in this project.

No libraries used.

Installation

  1. Clone the repository:
git clone https://github.com/kreslavskiy/graphs
  1. Run the program:
node src/commands.js

Usage

Type 'help' to see what which command does.

  1. To create a new graph just type 'new', then enter name of the graph and key field

Снимок экрана 2022-06-26 в 00 13 08

  1. 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.

Снимок экрана 2022-06-26 в 00 17 12

  1. 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

Снимок экрана 2022-06-26 в 00 22 12

  1. Now, when you have a graph of 2 vertices, you may want to see it. Use command 'show' for it!

Снимок экрана 2022-06-26 в 00 24 27

  1. If you created many vertices and you want to see concrete ones, you can use command 'select', and select vertices by data:

Снимок экрана 2022-06-27 в 00 05 23

or by links:

Снимок экрана 2022-06-27 в 00 06 09

or by both:

Снимок экрана 2022-06-27 в 00 06 39

  1. 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.

Снимок экрана 2022-06-26 в 00 28 24

Note: you can change even key field of data!

Снимок экрана 2022-06-26 в 00 31 37

  1. If you want to delete relation between vertices, use 'unlink' command.

Note: it works by one-to-many principle

Снимок экрана 2022-06-26 в 00 34 28

  1. Now we can delete usless vertex by using command 'delete'

Снимок экрана 2022-06-26 в 00 35 45

  1. You also can save your graph, type 'save', enter file name and it'll be saved in .json format.
  2. After saving, you can also open your graph in my program. Use command 'import' and enter file name.

Снимок экрана 2022-06-27 в 00 08 02

  1. 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

Снимок экрана 2022-06-27 в 00 09 42

  1. To delete all vertices at once use command 'clear', but you need to enter the name of graph to chack if you are sure.

Снимок экрана 2022-06-26 в 00 41 26

  1. 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.

Testing

To test the program, type node tests/tests.js, it expects everething to execute successfully.

Снимок экрана 2022-06-26 в 00 47 42

Then type node tests/testsErrors.js, it expects everything to throw errors.

Снимок экрана 2022-06-26 в 00 48 10

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published