Constructor for graph method