2D Moving on map trough lines

So I’d like to make a world map system on which you would travel trough a grid, I’ve made example


Lets say I am at point A and I have to move to B, but i have to travel trough point E first because grid doesn’t let me to. Does anybody have idea what kind of functions I could use? I’d like it in C#. Also it would be with mouse, like I press there and it goes there etc.
Thank you in advance!

So, you need to read up on graph theory.
Dijkstra is usually good.

It wasn’t what I really meant. But what I exactly want is just for example: I press there and it goes there. Or to some sort of object/asset on map that you press and it goes there. People will move manually and not automatically finding the shortest route (What I understand from that theory)

Still best to use A* or pathfinding.

Use unity’s built in or try the free version of A* Pathfinding Project - lets you link up lines.