To use an external Java library you need to add it to your classpath. The Java documentation has some great information on how to set it.
Assuming you're using the javac
compiler, you'll use a command similar to:
javac -classpath
path to jgrapht jar file...
other options and files here ...
See also: Compiling Java
You specifiacally mention Netbeans, so you'll also want to look at this question, and this blog post.
I hope this helps! :)