馃搫 Reposit贸rio Oficial do Pydot (GitHub)
| # | Comando / Fun莽茫o / Par芒metro | O que faz | Exemplo |
|---|---|---|---|
| 1 | pip install pydot | Instala莽茫o da biblioteca via PIP | !pip install pydot |
| 2 | import pydot | Importa a biblioteca principal | import pydot |
| 3 | pydot.Dot() | Cria um novo objeto de grafo | graph = pydot.Dot() |
| 4 | graph_type='graph' | Define o grafo como n茫o direcionado | pydot.Dot(graph_type='graph') |
| 5 | graph_type='digraph' | Define o grafo como direcionado (padr茫o) | pydot.Dot(graph_type='digraph') |
| 6 | pydot.Node() | Cria um novo n贸 | node = pydot.Node("A") |
| 7 | graph.add_node() | Adiciona um n贸 ao grafo | graph.add_node(node) |
| 8 | name= | Define o identificador do n贸 | pydot.Node(name="Inicio") |
| 9 | label= | Texto vis铆vel dentro do n贸 | node.set_label("Meu N贸") |
| 10 | shape='box' | Define o formato do n贸 como caixa | node.set_shape('box') |
| 11 | shape='circle' | Define o formato como c铆rculo | node.set_shape('circle') |
| 12 | shape='ellipse' | Define o formato como elipse | node.set_shape('ellipse') |
| 13 | shape='diamond' | Define o formato como diamante | node.set_shape('diamond') |
| 14 | style='filled' | Preenche o interior do n贸 | node.set_style('filled') |
| 15 | fillcolor= | Cor de preenchimento do n贸 | node.set_fillcolor('lightblue') |
| 16 | color= | Cor da borda do n贸 | node.set_color('red') |
| 17 | fontcolor= | Cor do texto do n贸 | node.set_fontcolor('blue') |
| 18 | fontsize= | Tamanho da fonte do n贸 | node.set_fontsize(12) |
| 19 | pydot.Edge() | Cria uma conex茫o entre dois n贸s | edge = pydot.Edge("A", "B") |
| 20 | graph.add_edge() | Adiciona a aresta ao grafo | graph.add_edge(edge) |
| 21 | label= | Adiciona texto 脿 linha da aresta | edge.set_label("conex茫o") |
| 22 | color= | Define a cor da linha da aresta | edge.set_color('green') |
| 23 | arrowhead= | Estilo da ponta da seta | edge.set_arrowhead('vee') |
| 24 | arrowsize= | Tamanho da ponta da seta | edge.set_arrowsize(2) |
| 25 | style='dashed' | Linha da aresta tracejada | edge.set_style('dashed') |
| 26 | style='dotted' | Linha da aresta pontilhada | edge.set_style('dotted') |
| 27 | penwidth= | Espessura da linha da aresta | edge.set_penwidth(2.5) |
| 28 | dir='both' | Dire莽茫o da seta (both, forward, back, none) | edge.set_dir('both') |
| 29 | graph.write_raw() | Salva o c贸digo DOT puro em arquivo | graph.write_raw('file.dot') |
| 30 | graph.write_png() | Exporta o grafo como imagem PNG | graph.write_png('output.png') |
| 31 | graph.write_pdf() | Exporta o grafo como PDF | graph.write_pdf('output.pdf') |
| 32 | graph.write_svg() | Exporta o grafo como vetor SVG | graph.write_svg('output.svg') |
| 33 | graph.write_jpg() | Exporta o grafo como imagem JPG | graph.write_jpg('output.jpg') |
| 34 | graph.to_string() | Retorna a representa莽茫o DOT em string | print(graph.to_string()) |
| 35 | pydot.graph_from_dot_file() | L锚 um arquivo .dot e cria um objeto | g = pydot.graph_from_dot_file('in.dot') |
| 36 | pydot.graph_from_dot_data() | Cria grafo a partir de string DOT | g = pydot.graph_from_dot_data(data) |
| 37 | rankdir='LR' | Orienta莽茫o Esquerda para Direita | graph.set_rankdir('LR') |
| 38 | rankdir='TB' | Orienta莽茫o Cima para Baixo (Padr茫o) | graph.set_rankdir('TB') |
| 39 | bgcolor= | Cor de fundo do grafo | graph.set_bgcolor('ivory') |
| 40 | label= | T铆tulo global do grafo | graph.set_label('Meu Fluxograma') |
| 41 | labelloc='t' | Posi莽茫o do t铆tulo (t: topo, b: base) | graph.set_labelloc('t') |
| 42 | nodesep= | Espa莽o entre n贸s em polegadas | graph.set_nodesep(0.5) |
| 43 | ranksep= | Espa莽o entre n铆veis do grafo | graph.set_ranksep(1.0) |
| 44 | splines='ortho' | Arestas em 芒ngulos retos | graph.set_splines('ortho') |
| 45 | concentrate=True | Mescla arestas paralelas em uma | graph.set_concentrate(True) |
| 46 | pydot.Cluster() | Cria um grupo de n贸s (caixa visual) | cluster = pydot.Cluster('c1') |
| 47 | graph.add_subgraph() | Adiciona um subgrafo ao principal | graph.add_subgraph(cluster) |
| 48 | label= | R贸tulo do cluster | cluster.set_label('M贸dulo A') |
| 49 | graph.get_nodes() | Retorna lista de todos os n贸s | nodes = graph.get_nodes() |
| 50 | graph.get_edges() | Retorna lista de todas as arestas | edges = graph.get_edges() |
| 51 | graph.get_node() | Busca um n贸 espec铆fico pelo nome | n = graph.get_node('A')[0] |
| 52 | graph.get_subgraphs() | Retorna lista de subgrafos | subs = graph.get_subgraphs() |
| 53 | graph.del_node() | Remove um n贸 do grafo | graph.del_node('A') |
| 54 | graph.del_edge() | Remove uma aresta espec铆fica | graph.del_edge('A', 'B') |
| 55 | shape='plaintext' | N贸 sem bordas, apenas texto | node.set_shape('plaintext') |
| 56 | fixedsize=True | For莽a o tamanho fixo do n贸 | node.set_fixedsize(True) |
| 57 | width= | Largura do n贸 | node.set_width(1.5) |
| 58 | height= | Altura do n贸 | node.set_height(0.5) |
| 59 | peripheries= | N煤mero de bordas conc锚ntricas | node.set_peripheries(2) |
| 60 | tooltip= | Texto ao passar o mouse (SVG/HTML) | node.set_tooltip('Dica') |
| 61 | constraint='false' | Aresta n茫o afeta o layout do ranking | edge.set_constraint('false') |
| 62 | weight= | Peso da aresta (import芒ncia no layout) | edge.set_weight(10) |
| 63 | minlen= | Comprimento m铆nimo da aresta | edge.set_minlen(2) |
| 64 | headlabel= | R贸tulo pr贸ximo 脿 ponta da seta | edge.set_headlabel('fim') |
| 65 | taillabel= | R贸tulo pr贸ximo ao in铆cio da seta | edge.set_taillabel('inicio') |
| 66 | labeldistance= | Dist芒ncia dos r贸tulos auxiliares | edge.set_labeldistance(3) |
| 67 | labelangle= | 脗ngulo dos r贸tulos auxiliares | edge.set_labelangle(45) |
| 68 | fontname= | Define a fam铆lia da fonte | node.set_fontname('Arial') |
| 69 | color='transparent' | Torna a borda invis铆vel | node.set_color('transparent') |
| 70 | colorscheme= | Usa esquemas de cores pr茅-definidos | node.set_colorscheme('spectral9') |
| 71 | pydot.__version__ | Verifica a vers茫o instalada | pydot.__version__ |
| 72 | pydot.find_graphviz() | Tenta localizar os bin谩rios do Graphviz | pydot.find_graphviz() |
| 73 | graph.create_png() | Retorna bytes da imagem PNG em mem贸ria | img_bytes = graph.create_png() |
| 74 | graph.create_dot() | Retorna bytes do formato DOT | dot_bytes = graph.create_dot() |
| 75 | prog='dot' | Usa o motor de layout DOT | graph.write_png('f.png', prog='dot') |
| 76 | prog='neato' | Usa motor de layout de mola | graph.write_png('f.png', prog='neato') |
| 77 | prog='fdp' | Layout para grafos n茫o direcionados | graph.write_png('f.png', prog='fdp') |
| 78 | prog='sfdp' | Layout para grafos gigantes | graph.write_png('f.png', prog='sfdp') |
| 79 | prog='twopi' | Layout radial | graph.write_png('f.png', prog='twopi') |
| 80 | prog='circo' | Layout circular | graph.write_png('f.png', prog='circo') |
| 81 | node.get_attributes() | Retorna dicion谩rio de atributos do n贸 | attrs = node.get_attributes() |
| 82 | edge.get_source() | Retorna o nome do n贸 de origem | src = edge.get_source() |
| 83 | edge.get_destination() | Retorna o nome do n贸 de destino | dst = edge.get_destination() |
| 84 | graph.set_type() | Muda tipo para 'graph' ou 'digraph' | graph.set_type('graph') |
| 85 | pydot.quote_if_necessary() | Escapa strings para sintaxe DOT | pydot.quote_if_necessary('N贸 1') |
| 86 | comment= | Adiciona coment谩rio no arquivo DOT | graph.set_comment('Gerado via Python') |
| 87 | overlap='false' | Evita sobreposi莽茫o de n贸s (layouts n茫o-dot) | graph.set_overlap('false') |
| 88 | ratio='fill' | Ajusta propor莽茫o da imagem | graph.set_ratio('fill') |
| 89 | size="10,10!" | For莽a tamanho m谩ximo da imagem final | graph.set_size("10,10!") |
| 90 | charset="UTF-8" | Define codifica莽茫o de caracteres | graph.set_charset("UTF-8") |
| 91 | pydot.call_graphviz() | Chamada direta de baixo n铆vel ao Graphviz | pydot.call_graphviz('dot', ...) |