class_docstr: A GraphItem displays graph information as
  a set of nodes connected by lines (as in 'graph theory', not 'graphics'). 
  Useful for drawing networks, trees, etc.
class_docstr_tok: ["A","GraphItem","displays","graph","information","as","a","set","of","nodes","connected","by","lines","(","as","in","'graph","theory","'",",","not","'graphics","'",")",".","Useful","for","drawing","networks",",","trees",",","etc","."]
code: def generatePicture(self):
      self.picture = QtGui.QPicture()
      if self.pen is None or self.pos is None or self.adjacency is None:
          return
  
      p = QtGui.QPainter(self.picture)
      try:
          pts = self.pos[self.adjacency]
          pen = self.pen
          if isinstance(pen, np.ndarray):
              lastPen = None
              for i in range(pts.shape[0]):
                  pen = self.pen[i]
                  if lastPen is None or np.any(pen != lastPen):
                      lastPen = pen
                      if pen.dtype.fields is None:
                          p.setPen(
                              fn.mkPen(
                                  color=(
                                      pen[0],
                                      pen[1],
                                      pen[2],
                                      pen[3],
                                  ),
                                  width=1,
                              )
                          )
                      else:
                          p.setPen(
                              fn.mkPen(
                                  color=(
                                      pen["red"],
                                      pen["green"],
                                      pen["blue"],
                                      pen["alpha"],
                                  ),
                                  width=pen["width"],
                              )
                          )
                  p.drawLine(
                      QtCore.QPointF(*pts[i][0]),
                      QtCore.QPointF(*pts[i][1]),
                  )
          else:
              if pen == "default":
                  pen = getConfigOption("foreground")
              p.setPen(fn.mkPen(pen))
              pts = pts.reshape(
                  (pts.shape[0] * pts.shape[1], pts.shape[2])
              )
              path = fn.arrayToQPath(
                  x=pts[:, 0], y=pts[:, 1], connect="pairs"
              )
              p.drawPath(path)
      finally:
          p.end()
  
file_path: pyqtgraph/pyqtgraph/graphicsItems/GraphItem.py
imports: import numpy
  from ..None import functions
  from ..None import getConfigOption
  from ..Qt import QtCore, QtGui
  from .GraphicsObject import GraphicsObject
  from .ScatterPlotItem import ScatterPlotItem
label_desc: Use image node_id 5 for calling the GraphItem obj's underlying member method code with example usage: obj.generatePicture() without return types