Bfs and Dfs implemented. No visuals yet
This commit is contained in:
parent
4cc9ab073d
commit
5fc5f8b3d8
|
@ -8,9 +8,13 @@ class CurvePainter extends CustomPainter {
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.graphData,
|
required this.graphData,
|
||||||
required this.bfsPath,
|
required this.bfsPath,
|
||||||
|
required this.dfsStart,
|
||||||
|
required this.dfsAccessTable,
|
||||||
});
|
});
|
||||||
|
|
||||||
List<int>? bfsPath;
|
List<int>? bfsPath;
|
||||||
|
List<bool>? dfsAccessTable;
|
||||||
|
int? dfsStart;
|
||||||
Graphs graphData;
|
Graphs graphData;
|
||||||
final double dotRad = 6;
|
final double dotRad = 6;
|
||||||
final double lineWidth = 2;
|
final double lineWidth = 2;
|
||||||
|
|
|
@ -25,6 +25,8 @@ class _DrawingPageState extends State<DrawingPage> {
|
||||||
double screenSize = 0;
|
double screenSize = 0;
|
||||||
Graphs graphData = getGraph();
|
Graphs graphData = getGraph();
|
||||||
List<int>? bfsPath;
|
List<int>? bfsPath;
|
||||||
|
List<bool>? dfsAccessTable;
|
||||||
|
int? dfsStartDot;
|
||||||
|
|
||||||
final _textNameController = TextEditingController();
|
final _textNameController = TextEditingController();
|
||||||
final _textNumbController = TextEditingController();
|
final _textNumbController = TextEditingController();
|
||||||
|
@ -86,20 +88,24 @@ class _DrawingPageState extends State<DrawingPage> {
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: clearScreen,
|
onPressed: () => graphData.flushData(),
|
||||||
icon: const Icon(Icons.delete_sweep),
|
icon: const Icon(Icons.delete_sweep),
|
||||||
iconSize: 60,
|
iconSize: 60,
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
body: CustomPaint(
|
body: CustomPaint(
|
||||||
painter: CurvePainter(graphData: graphData, bfsPath: bfsPath),
|
painter: CurvePainter(
|
||||||
|
graphData: graphData,
|
||||||
|
bfsPath: bfsPath,
|
||||||
|
dfsStart: dfsStartDot,
|
||||||
|
dfsAccessTable: dfsAccessTable),
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.topRight,
|
alignment: Alignment.topRight,
|
||||||
child: ButtonBar(
|
child: ButtonBar(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
createButton("Bfs", bfsPushed),
|
createButton("Bfs", bfsPushed),
|
||||||
createButton("Dfs", () {}),
|
createButton("Dfs", dfsPushed),
|
||||||
createButton("Clear dfs or bfs", () => bfsPath = null),
|
createButton("Clear dfs or bfs", () => bfsPath = null),
|
||||||
createButton(graphData.getUseLengthStr(), changeLength),
|
createButton(graphData.getUseLengthStr(), changeLength),
|
||||||
createButton(graphData.getDoubleSidedStr(), changeOriented),
|
createButton(graphData.getDoubleSidedStr(), changeOriented),
|
||||||
|
@ -357,6 +363,8 @@ class _DrawingPageState extends State<DrawingPage> {
|
||||||
|
|
||||||
void bfsPushed() {
|
void bfsPushed() {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
dfsAccessTable = null;
|
||||||
|
bfsPath = null;
|
||||||
if (_textNumbController.text == "") {
|
if (_textNumbController.text == "") {
|
||||||
showPopUp("Error", "No number in \"Dot number\" box");
|
showPopUp("Error", "No number in \"Dot number\" box");
|
||||||
} else if (_textDestController.text == "") {
|
} else if (_textDestController.text == "") {
|
||||||
|
@ -379,6 +387,27 @@ class _DrawingPageState extends State<DrawingPage> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearScreen() => graphData.flushData();
|
void dfsPushed() {
|
||||||
|
setState(() {
|
||||||
|
bfsPath = null;
|
||||||
|
bfsPath = null;
|
||||||
|
if (_textNumbController.text == "") {
|
||||||
|
showPopUp("Error", "No number in \"Dot number\" box");
|
||||||
|
} else {
|
||||||
|
int? from = int.tryParse(_textNumbController.text);
|
||||||
|
if (from == null) {
|
||||||
|
showPopUp("Error",
|
||||||
|
"Can't parse input.\nInts only allowed in \"Dot number\".");
|
||||||
|
} else {
|
||||||
|
dfsAccessTable = graphData.dfsIterative(from);
|
||||||
|
if (dfsAccessTable == null) {
|
||||||
|
showPopUp("Err", "report this error.");
|
||||||
|
}
|
||||||
|
print(dfsAccessTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clearTextControllers();
|
||||||
|
});
|
||||||
|
}
|
||||||
//*********ButtonsFunctions*********
|
//*********ButtonsFunctions*********
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 1.0.0+1
|
version: 0.5.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.15.0-100.0.dev<3.0.0"
|
sdk: ">=2.15.0-100.0.dev<3.0.0"
|
||||||
|
|
|
@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||||
FlutterWindow window(project);
|
FlutterWindow window(project);
|
||||||
Win32Window::Point origin(10, 10);
|
Win32Window::Point origin(10, 10);
|
||||||
Win32Window::Size size(1280, 720);
|
Win32Window::Size size(1280, 720);
|
||||||
if (!window.CreateAndShow(L"grafs", origin, size)) {
|
if (!window.CreateAndShow(L"graphs", origin, size)) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
window.SetQuitOnClose(true);
|
window.SetQuitOnClose(true);
|
||||||
|
|
Loading…
Reference in New Issue