Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Enchente
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vytor Calixto
Enchente
Commits
f79f11ac
There was a problem fetching the pipeline summary.
Commit
f79f11ac
authored
May 15, 2017
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Add função para imprimir grafo em formato .dot
parent
7179a2d3
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
libs/grafo.c
+21
-0
21 additions, 0 deletions
libs/grafo.c
libs/grafo.h
+3
-0
3 additions, 0 deletions
libs/grafo.h
main.c
+9
-1
9 additions, 1 deletion
main.c
tests/runTests.sh
+2
-2
2 additions, 2 deletions
tests/runTests.sh
with
36 additions
and
3 deletions
.gitignore
+
1
−
0
View file @
f79f11ac
...
@@ -7,3 +7,4 @@ test
...
@@ -7,3 +7,4 @@ test
tests/*.txt
tests/*.txt
tests/*.png
tests/*.png
massif.out*
massif.out*
*.out
This diff is collapsed.
Click to expand it.
libs/grafo.c
+
21
−
0
View file @
f79f11ac
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include
"lista.h"
#include
"lista.h"
#include
"vertice.h"
#include
"vertice.h"
#include
"tabuleiro.h"
#include
"tabuleiro.h"
#include
<stdio.h>
Grafo
criaGrafo
()
{
Grafo
criaGrafo
()
{
Grafo
g
=
malloc
(
sizeof
(
struct
Grafo
));
Grafo
g
=
malloc
(
sizeof
(
struct
Grafo
));
...
@@ -117,3 +118,23 @@ void destroiGrafo(Grafo g) {
...
@@ -117,3 +118,23 @@ void destroiGrafo(Grafo g) {
g
=
NULL
;
g
=
NULL
;
return
;
return
;
}
}
void
grafoParaDot
(
Grafo
g
,
Lista
grupo
,
FILE
*
fp
)
{
fprintf
(
fp
,
"strict graph g {
\n
"
);
// Pinta os nós que estão no grupo de vermelho
for
(
No
n
=
primeiroNoLista
(
grupo
);
n
;
n
=
getSucessorNo
(
n
))
{
Vertice
v
=
(
Vertice
)
getConteudo
(
n
);
fprintf
(
fp
,
"
\t\"
%p
\"
[color=red];
\n
"
,
v
);
}
// Imprime o grafo
for
(
No
n
=
primeiroNoLista
(
g
->
vertices
);
n
;
n
=
getSucessorNo
(
n
))
{
Vertice
pai
=
(
Vertice
)
getConteudo
(
n
);
fprintf
(
fp
,
"
\t\"
%p
\"
[label=
\"
cor=%d,peso=%d
\"
];
\n
"
,
pai
,
pai
->
cor
,
pai
->
peso
);
for
(
No
m
=
primeiroNoLista
(
pai
->
filhos
);
m
;
m
=
getSucessorNo
(
m
))
{
Vertice
filho
=
(
Vertice
)
getConteudo
(
m
);
fprintf
(
fp
,
"
\t\"
%p
\"
[label=
\"
cor=%d,peso=%d
\"
];
\n
"
,
filho
,
filho
->
cor
,
filho
->
peso
);
fprintf
(
fp
,
"
\t\"
%p
\"
--
\"
%p
\"
;
\n
"
,
pai
,
filho
);
}
}
fprintf
(
fp
,
"}
\n
"
);
}
This diff is collapsed.
Click to expand it.
libs/grafo.h
+
3
−
0
View file @
f79f11ac
#ifndef _GRAFO_
#ifndef _GRAFO_
#define _GRAFO_
#define _GRAFO_
#include
"tabuleiro.h"
#include
"tabuleiro.h"
#include
<stdio.h>
struct
Grafo
{
struct
Grafo
{
Lista
vertices
;
Lista
vertices
;
...
@@ -18,4 +19,6 @@ void tabuleiroParaGrafo(Tblr t, Grafo g);
...
@@ -18,4 +19,6 @@ void tabuleiroParaGrafo(Tblr t, Grafo g);
void
destroiGrafo
(
Grafo
g
);
void
destroiGrafo
(
Grafo
g
);
void
grafoParaDot
(
Grafo
g
,
Lista
grupo
,
FILE
*
fp
);
#endif
#endif
This diff is collapsed.
Click to expand it.
main.c
+
9
−
1
View file @
f79f11ac
...
@@ -26,9 +26,17 @@ int main() {
...
@@ -26,9 +26,17 @@ int main() {
// Desaloca tabuleiro
// Desaloca tabuleiro
destroiTblr
(
t
);
destroiTblr
(
t
);
// printf("Número de grupos: %d\n", tamanhoLista(g->vertices));
Lista
jogadas
=
constroiLista
();
Lista
jogadas
=
constroiLista
();
// PARA DEBUGAR: Imprime o grafo tabuleiro em formato dot com os vértices já
// "consumidos" pintados de vermelho
printf
(
"Número de grupos: %d
\n
"
,
tamanhoLista
(
g
->
vertices
));
FILE
*
debug
=
fopen
(
"./debug.out"
,
"w+"
);
if
(
debug
)
{
grafoParaDot
(
g
,
grupo
,
debug
);
}
fclose
(
debug
);
destroiLista
(
jogadas
,
NULL
);
destroiLista
(
jogadas
,
NULL
);
// Desaloca lista do grupo
// Desaloca lista do grupo
destroiLista
(
grupo
,
NULL
);
destroiLista
(
grupo
,
NULL
);
...
...
This diff is collapsed.
Click to expand it.
tests/runTests.sh
+
2
−
2
View file @
f79f11ac
...
@@ -4,10 +4,10 @@
...
@@ -4,10 +4,10 @@
tempo_max
=
10000
#10s
tempo_max
=
10000
#10s
# tamanhos do tabuleiro
# tamanhos do tabuleiro
tams
=(
4 8 16
25 32 50 64 75 100 128
)
tams
=(
4 8 16
32 64 128 256
)
# lista de cores
# lista de cores
cores
=(
2
3 4 5 6 7 8 10
16 32
)
cores
=(
2
4 8
16 32
)
#-- Cores do terminal
#-- Cores do terminal
RED
=
'\033[0;31m'
RED
=
'\033[0;31m'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment