For installing from Macports or Homebrew, you are best off referring to their websites that give good introductions to what they are and how you would use them to install software like Graphviz.
If you’re asking how you would build Graphviz yourself from source, you should probably refer to the paths for “Darwin” in the ci/build.sh we run in regular testing. In short, you probably want something like:
git clone https://gitlab.com/graphviz/graphviz -b 2.47.0
./configure --prefix=/opt/graphviz-2.47.0 --with-quartz=yes
This will build and install Graphviz 2.47.0 to /opt/graphviz-2.47.0. To get this working though, you will need all the build dependencies we install in CI, .gitlab-ci.yml · main · graphviz / graphviz · GitLab.