You don't even need an intervening router or network switch/hub. A direct connection between the two will do just as well and, what's more, you get a choice of cable (depending on hardware) you can use.
You can use either an ethernet cable or a lightning cable or even a firewire cable if you've computers that are old enough to offer that connectivity. I may be teaching granny to suck eggs but, just in case, all three connection methods support TCP/IP which is an underlying network protocol that assigns IP addresses to networked devices. Once connected you don't have to do anything special either, as the two computers will each automatically assign themselves an IP address and provided you've enabled Remote Management in the Sharing Preferences Pane on the one computer you wish to control/view/screenshare with then you're good to go.
I've done all of the above from my laptop to rack mounted headless servers that happen to be in heavily-secured networks where VNC is blocked across subnets. The only way in this case to access them is by directly connecting a cable.