public bool isBipartite <T>(Graph graph, int nodes_count, int[] colorArr, GraphTypes graphType, int[] conn_comps)//remove scr { bool[] discovered = new bool[nodes_count + 1]; for (int i = 0; i < nodes_count; ++i) { colorArr[i] = -1; } isConnectedflag = true; bipartiteflag = true; for (int i = 0; i < nodes_count; i++) { if (colorArr[i] == -1) { componentlistIndex++; isBipartite_util(graph.getData <T>(), i, nodes_count, colorArr, graphType, conn_comps); if (i == 0) { for (int j = 0; j < nodes_count; ++j) { if (colorArr[j] == -1) { isConnectedflag = false; } } } } } if (bipartiteflag == true) { return(true); } return(false); }
/// <summary> /// Returns complete graph. /// Each node is connected to each other node. /// </summary> /// <param name="numberOfNodes">Number of nodes in generated graph. Higher than 0.</param> /// <param name="graphType">Graph type, defaults to <see cref="GraphTypes.GraphFastDirected"/></param> /// <returns>A complete graph with specified number of nodes.</returns> public BaseGraph CompleteGraph(int numberOfNodes, GraphTypes graphType = GraphTypes.GraphFastDirected) { if (numberOfNodes < 1) { throw new ArgumentOutOfRangeException("numberOfNodes", numberOfNodes, "Value of numberOfNodes should be higher than 0"); } BaseGraph graph = graphFactory.GetGraph(graphType); List <int> nodes = Enumerable.Range(0, numberOfNodes).ToList(); graph.NodeAdd(nodes); foreach (int node1 in graph.Nodes) { foreach (int node2 in graph.Nodes) { if (node1 != node2) { graph.EdgeAdd(node1, node2); } } } return(graph); }
public Data(double[] data, double[] sign, string name, GraphTypes type = GraphTypes.POINT) { this.data = data; this.sign = sign; this.name = name; this.type = type; }
public static extern int algorithm_Algorithm_run(UpdaterTypes updater_type, IntPtr ising, IsingTypes ising_type, GraphTypes graph_type, FloatTypes float_type, IntPtr random_number_engine, IntPtr schedule_list);
public Data(double[] data, string name, GraphTypes type = GraphTypes.POINT) { this.data = data; sign = Enumerable.Range(0, data.Length).Select(x => (double)x).ToArray(); this.name = name; this.type = type; }
public static GraphTypes Prev(this GraphTypes graphType) { if (graphType == GraphTypes.NutritionAndJumpmen) { return(GraphTypes.AverageSpeedAndSize); } return((GraphTypes)((int)graphType - 1)); }
public MatrixGraph(GraphTypes type, int verticesNumber = 0) { Type = type; Vertices = verticesNumber; if (verticesNumber != 0) { Graph = new int[verticesNumber, verticesNumber]; } }
public void ShowGrowthChart(GrowthTypes growth, GraphTypes graph, Sexes sex, double x, double y, string title) { var parameters = new ModalParameters(); parameters.Add(nameof(Chart.Growth), growth); parameters.Add(nameof(Chart.Graph), graph); parameters.Add(nameof(Chart.Sex), sex); parameters.Add(nameof(Chart.X), x); parameters.Add(nameof(Chart.Y), y); Modal.Show <Chart>(SetChartTitle(title, sex), parameters); }
public async Task <string> GetWfa(byte id, byte x, double y, GraphTypes z) { Uri newUri = new(httpClient.BaseAddress + $"chart/WFA/{id}/{x}/{y}/{z}"); var response = await httpClient.GetAsync(newUri).ConfigureAwait(false); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync().ConfigureAwait(false); return(responseBody); }
private void rbtnLine_CheckedChanged(object sender, EventArgs e) { if (rbtnBar.Checked) { graphTypes = GraphTypes.Bar; } if (rbtnLine.Checked) { graphTypes = GraphTypes.Linear; } delegateUpdateActiveGui(); }
public async Task <string> GetAllTSFAJson(byte id, byte x, decimal y, GraphTypes z) { Chart chart = new(_context); List <TsfforAge> result = await chart.ListTsfforAge((Sexes)id, x, y); ChartDataTable gChart = new(); gChart.cols = ChartDataTable.GetCols(z, GrowthTypes.TSF); gChart.rows = ChartDataTable.GetTsfRows(z, GrowthTypes.TSF, result); string sJson = JsonSerializer.Serialize(gChart); return(sJson); }
public Data(Func <double, double> func, double start, double step, double end, string name, GraphTypes type = GraphTypes.LINE) { List <double> data = new List <double>(), sign = new List <double>(); for (double i = start; i <= end; i += step) { data.Add(func(i)); sign.Add(i); } this.data = data.ToArray(); this.sign = sign.ToArray(); this.name = name; this.type = type; }
public async Task <string> GetAllWFLJson(byte id, decimal x, decimal y, GraphTypes z) { Chart chart = new(_context); List <WeightForLength> result = await chart.ListWeightForLength((Sexes)id, x, y); ChartDataTable gChart = new(); gChart.cols = ChartDataTable.GetCols(z, GrowthTypes.WFL); gChart.rows = ChartDataTable.GetWflRows(z, GrowthTypes.WFL, result); string sJson = JsonSerializer.Serialize(gChart); return(sJson); }
public async Task <string> GetAllLHFAJson(byte id, byte x, decimal y, GraphTypes z) { Chart chart = new(_context); List <LengthHeightForAge> result = await chart.ListLengthHeightForAge((Sexes)id, x, y); ChartDataTable gChart = new(); gChart.cols = ChartDataTable.GetCols(z, GrowthTypes.LHFA); gChart.rows = ChartDataTable.GetLhfaRows(z, GrowthTypes.LHFA, result); string sJson = JsonSerializer.Serialize(gChart); return(sJson); }
private void rbtnLine_CheckedChanged(object sender, EventArgs e) { if (rbtnBar.Checked == true) { m_graphTypes = GraphTypes.Bar; } else if (rbtnLine.Checked == true) { m_graphTypes = GraphTypes.Linear; } else { ; } delegateUpdateActiveGui((int)TYPE_UPDATEGUI.LINEAR); }
/// <summary> /// Закрытый метод rbtnLine_CheckedChanged (проверка изменения типа графика), /// принимающий события нажатия на кнопку "линейный" или "гистограмма" /// </summary> /// <param name="sender">Объект, инициировавший событие</param> /// <param name="e">Аргумент события</param> private void rbtnTypeGraph_CheckedChanged(object sender, EventArgs e) { foreach (RadioButton rbtn in m_arRbtnTypeGraph) { if (rbtn.Checked == true) { m_graphTypes = (GraphTypes)(rbtn as Control).Tag; break; } else { ; } } delegateUpdateActiveGui((int)TYPE_UPDATEGUI.LINEAR); //обновить активную настройку (тип графика) }
/// <summary> /// Закрытый метод rbtnLine_CheckedChanged (проверка изменения типа графика), /// принимающий события нажатия на кнопку "линейный" или "гистограмма" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void rbtnLine_CheckedChanged(object sender, EventArgs e) { if (rbtnBar.Checked == true) //если кнопка "гистограмма" нажата { m_graphTypes = GraphTypes.Bar; // полю m_graphTypes присвоить "гистрограмма" } else if (rbtnLine.Checked == true) //если кнопка "линейный" нажата { m_graphTypes = GraphTypes.Linear; // полю m_graphTypes присвоить "линейный" } else { ; } delegateUpdateActiveGui((int)TYPE_UPDATEGUI.LINEAR); //обновить активную настройку (линейный) }
public BaseGraph GetGraph(GraphTypes graphType) { switch (graphType) { case GraphTypes.GraphFastDirected: return(new GraphFastDirected()); case GraphTypes.GraphFastUndirected: return(new GraphFastUndirected()); case GraphTypes.GraphDirected: throw new NotImplementedException(); case GraphTypes.GraphUndirected: throw new NotImplementedException(); default: throw new NotImplementedException(); } }
/// <summary> /// Открытый пользовательский конструктор FormGraphicsSettings инициализирует поля m_formMain, delegateUpdateActiveGui, delegateHideGraphicsSettings /// </summary> /// <param name="form">Родительская форма - главное окно приложения</param> /// <param name="fUpdate">Метод для применения изменений</param> /// <param name="fHide">Метод снятия с отображения диалогового окна</param> /// <param name="bAllowedChangeShema">Признак(настраиваемый из БД) разрешения изменять цветовую схему</param> public FormGraphicsSettings(DelegateIntFunc fUpdate, DelegateFunc fHide, bool bAllowedChangeShema) { // инициализация полей заданными пользователем значениями delegateUpdateActiveGui = fUpdate; delegateHideGraphicsSettings = fHide; _allowedChangeShema = bAllowedChangeShema; //масштабирование выключено по умолчанию scale = false; // полю m_markSourceData присваиваем ссылку на экземпляр класса HMark, вызываем конструктор HMark с одним параметром, передаем 0 m_markSourceData = new HMark(0); InitializeComponent(); bool bGroupBoxSourceData = false; //переменной bGroupBoxSourceData присваиваем false CONN_SETT_TYPE cstGroupBoxSourceData = CONN_SETT_TYPE.AISKUE_3_MIN; //переменной cstGroupBoxSourceData присваиваем константу=1 (AISKUE_3_MIN) //Проверка условия прав доступа к возможности смены источника данных if (HStatisticUsers.IsAllowed((int)HStatisticUsers.ID_ALLOWED.SOURCEDATA_CHANGED) == true) //if (m_formMain.m_users.IsAllowed(HStatisticUsers.ID_ALLOWED.SOURCEDATA_CHANGED) == true) //if ((HStatisticUsers.RoleIsAdmin == true) || (HStatisticUsers.RoleIsKomDisp == true)) { bGroupBoxSourceData = true; //переменной bGroupBoxSourceData присваиваем true (групповой источник данных) cstGroupBoxSourceData = CONN_SETT_TYPE.COSTUMIZE; //переменной cstGroupBoxSourceData присваиваем константу=4 (по умолчанию установлен COSTUMIZE) //кнопки АИСКУЭ+СОТИАССО и СОТИАССО(3 мин) становятся активными (да вроде все активные..?) m_arRbtnSourceData [(int)CONN_SETT_TYPE.AISKUE_PLUS_SOTIASSO].Enabled = HStatisticUsers.IsAllowed((int)HStatisticUsers.ID_ALLOWED.SOURCEDATA_ASKUE_PLUS_SOTIASSO); m_arRbtnSourceData [(int)CONN_SETT_TYPE.SOTIASSO_3_MIN].Enabled = HStatisticUsers.IsAllowed((int)HStatisticUsers.ID_ALLOWED.SOURCEDATA_SOTIASSO_3_MIN); } else { ; } this.gbxSourceData.Enabled = bGroupBoxSourceData; //?? m_markSourceData.Marked((int)cstGroupBoxSourceData); checkedSourceData(); // вызов метода проверки источника данных m_graphTypes = GraphTypes.Bar; // тип графика-Гистограмма по умолчанию }
public FormGraphicsSettings(FormMain fm, DelegateIntFunc delUp, DelegateFunc Hide) { InitializeComponent(); delegateUpdateActiveGui = delUp; delegateHideGraphicsSettings = Hide; m_formMain = fm; scale = false; m_markSourceData = new HMark(0); bool bGroupBoxSourceData = false; CONN_SETT_TYPE cstGroupBoxSourceData = CONN_SETT_TYPE.AISKUE_3_MIN; //Проверка условия прав доступа к возможности смены источника данных if (HStatisticUsers.IsAllowed((int)HStatisticUsers.ID_ALLOWED.SOURCEDATA_CHANGED) == true) //if (m_formMain.m_users.IsAllowed(HStatisticUsers.ID_ALLOWED.SOURCEDATA_CHANGED) == true) //if ((HStatisticUsers.RoleIsAdmin == true) || (HStatisticUsers.RoleIsKomDisp == true)) { bGroupBoxSourceData = true; cstGroupBoxSourceData = CONN_SETT_TYPE.COSTUMIZE; m_arRadioButtonSourceData[(int)CONN_SETT_TYPE.AISKUE_PLUS_SOTIASSO].Enabled = HStatisticUsers.IsAllowed((int)HStatisticUsers.ID_ALLOWED.SOURCEDATA_ASKUE_PLUS_SOTIASSO); m_arRadioButtonSourceData[(int)CONN_SETT_TYPE.SOTIASSO_3_MIN].Enabled = HStatisticUsers.IsAllowed((int)HStatisticUsers.ID_ALLOWED.SOURCEDATA_SOTIASSO_3_MIN); } else { ; } this.groupBoxSourceData.Enabled = bGroupBoxSourceData; m_markSourceData.Marked((int)cstGroupBoxSourceData); checkedSourceData(); m_graphTypes = GraphTypes.Bar; //Гистограмма }
public void ReloadGraph(GraphTypes gt) { RaiseFeedback("Has not been implemented yet"); return; //Remove all nodes and edges, wipe lists and reload foreach (Edge e in AllEdges.Values) { e.gameObject.SetActive(false); //DestroyImmediate(e.gameObject); } foreach (Node n in AllNodes.Values) { n.gameObject.SetActive(false); //DestroyImmediate(n.gameObject); } this.AllEdges = new Dictionary <uint, Edge>(); this.AllNodes = new Dictionary <string, Node>(); switch (gt) { case GraphTypes.Neo4jLocal: AR.Core.Communications.Neo4jConnector.getInstance().GetGraphFromQuery(this, "MATCH p=()-[r:ORDERS]->() RETURN p LIMIT 100", true); break; case GraphTypes.Simple: AR.Core.Communications.GraphMLGraphFactory.GetGraphFromURL(this, AR.Core.Types.GraphConfiguration.URL_SIMPLEGRAPH); break; case GraphTypes.Sample: AR.Core.Communications.GraphMLGraphFactory.GetGraphFromURL(this, AR.Core.Types.GraphConfiguration.URL_SAMPLEGRAPH); break; default: break; } }
public GraphicsSettings(MainForm mf, DelegateFunc delUp, DelegateFunc Hide) { InitializeComponent(); delegateUpdateActiveGui = delUp; delegateHideGraphicsSettings = Hide; mainForm = mf; scale = false; udgColor = Color.FromArgb(0, 0, 0); lblUDGcolor.BackColor = udgColor; lblUDGcolor.ForeColor = Color.FromArgb((udgColor.R + 128) % 256, (udgColor.G + 128) % 256, (udgColor.B + 128) % 256); divColor = Color.FromArgb(255, 0, 0); lblDIVcolor.BackColor = divColor; lblDIVcolor.ForeColor = Color.FromArgb((divColor.R + 128) % 256, (divColor.G + 128) % 256, (divColor.B + 128) % 256); pColor = Color.FromArgb(0, 128, 0); lblPcolor.BackColor = pColor; lblPcolor.ForeColor = Color.FromArgb((pColor.R + 128) % 256, (pColor.G + 128) % 256, (pColor.B + 128) % 256); recColor = Color.FromArgb(255, 255, 0); lblRECcolor.BackColor = recColor; lblRECcolor.ForeColor = Color.FromArgb((recColor.R + 128) % 256, (recColor.G + 128) % 256, (recColor.B + 128) % 256); bgColor = Color.FromArgb(230, 230, 230); lblBGcolor.BackColor = bgColor; lblBGcolor.ForeColor = Color.FromArgb((bgColor.R + 128) % 256, (bgColor.G + 128) % 256, (bgColor.B + 128) % 256); gridColor = Color.FromArgb(200, 200, 200); lblGRIDcolor.BackColor = gridColor; lblGRIDcolor.ForeColor = Color.FromArgb((gridColor.R + 128) % 256, (gridColor.G + 128) % 256, (gridColor.B + 128) % 256); graphTypes = GraphTypes.Bar; }
public async Task<string> GetChartData(byte id, double x, double y, GraphTypes z) { string data = string.Empty; switch (Growth) { case GrowthTypes.BFA: data = await ChartService.GetBfa(id, (byte)x, y, z).ConfigureAwait(false); break; case GrowthTypes.HCA: data = await ChartService.GetHcfa(id, (byte)x, y, z).ConfigureAwait(false); break; case GrowthTypes.LHFA: data = await ChartService.GetLhfa(id, (byte)x, y, z).ConfigureAwait(false); break; case GrowthTypes.MUAC: data = await ChartService.GetMuac(id, (byte)x, y, z).ConfigureAwait(false); break; case GrowthTypes.SSF: data = await ChartService.GetSsfa(id, (byte)x, y, z).ConfigureAwait(false); break; case GrowthTypes.TSF: data = await ChartService.GetTsfa(id, (byte)x, y, z).ConfigureAwait(false); break; case GrowthTypes.WFA: data = await ChartService.GetWfa(id, (byte)x, y, z).ConfigureAwait(false); break; case GrowthTypes.WFH: data = await ChartService.GetWfh(id, x, y, z).ConfigureAwait(false); break; case GrowthTypes.WFL: data = await ChartService.GetWfl(id, x, y, z).ConfigureAwait(false); break; } return data; }
/// <summary> /// Gets the text for chart title. /// </summary> /// <param name="growth">The growth chart measure.</param> /// <returns>Returns a string for X-axis title.</returns> public static string GetTitle(GraphTypes graph, GrowthTypes growth) { string title = string.Empty; switch (graph) { case GraphTypes.PValue: switch (growth) { case GrowthTypes.BFA: title = "Birth to 5 Years (Percentile)"; break; case GrowthTypes.HCA: title = "Birth to 5 Years (Percentile)"; break; case GrowthTypes.LHFA: title = "Birth to 5 Years (Percentile)"; break; case GrowthTypes.MUAC: title = "Birth to 5 Years (Percentile)"; break; case GrowthTypes.SSF: title = "Birth to 5 Years (Percentile)"; break; case GrowthTypes.TSF: title = "Birth to 5 Years (Percentile)"; break; case GrowthTypes.WFA: title = "Birth to 5 Years (Percentile)"; break; case (GrowthTypes.WFL): title = "Birth to 5 Years (Percentile)"; break; case (GrowthTypes.WFH): title = "Birth to 5 Years (Percentile)"; break; } break; case GraphTypes.ZScore: switch (growth) { case GrowthTypes.BFA: title = "Birth to 5 Years (Z-scores)"; break; case GrowthTypes.HCA: title = "Birth to 5 Years (Z-scores)"; break; case GrowthTypes.LHFA: title = "Birth to 5 Years (Z-scores)"; break; case GrowthTypes.MUAC: title = "Birth to 5 Years (Z-scores)"; break; case GrowthTypes.SSF: title = "Birth to 5 Years (Z-scores)"; break; case GrowthTypes.TSF: title = "Birth to 5 Years (Z-scores)"; break; case GrowthTypes.WFA: title = "Birth to 5 Years (Z-scores)"; break; case (GrowthTypes.WFL): title = "Birth to 5 Years (Z-scores)"; break; case (GrowthTypes.WFH): title = "Birth to 5 Years (Z-scores)"; break; } break; } return(title); }
/// <summary> /// Copies the elements of the List<Series> to a new array. /// </summary> /// <param name="graph"></param> /// <param name="growth"></param> /// <returns>Returns an array containing copies of the elements of the List<Series>.</returns> public static Series[] GetSeries(GraphTypes graph, GrowthTypes growth) { List <Series> series = new(); switch (graph) { case (GraphTypes.PValue): switch (growth) { case GrowthTypes.BFA: case GrowthTypes.HCA: case GrowthTypes.LHFA: case GrowthTypes.MUAC: case GrowthTypes.SSF: case GrowthTypes.TSF: case GrowthTypes.WFA: case (GrowthTypes.WFL): case (GrowthTypes.WFH): series.Add(new Series { color = "#e10808", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#ffd700", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#0c8d00", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#ffd700", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#e10808", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "blue", visibleInLegend = false, type = "scatter", pointSize = 20 }); break; } break; case (GraphTypes.ZScore): switch (growth) { case GrowthTypes.BFA: case GrowthTypes.HCA: case GrowthTypes.MUAC: case GrowthTypes.SSF: case GrowthTypes.TSF: case (GrowthTypes.WFL): case (GrowthTypes.WFH): series.Add(new Series { color = "#000000", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#e10808", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#ffd700", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#0c8d00", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#ffd700", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#e10808", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#000000", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "blue", visibleInLegend = false, type = "scatter", pointSize = 20 }); break; case GrowthTypes.LHFA: case GrowthTypes.WFA: series.Add(new Series { color = "#000000", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#e10808", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#0c8d00", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#e10808", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "#000000", visibleInLegend = true, type = "linear", pointSize = 0 }); series.Add(new Series { color = "blue", visibleInLegend = false, type = "scatter", pointSize = 20 }); break; } break; } // Gets items from Series list Series[] array = series.ToArray(); return(array); }
public JsonResult GetItensChart(DateTime date, GraphTypes type) { object itens = new List <int>(); var title = ""; var yAxesTitle = "Hit"; var color = "#4169E1"; try { switch (type) { case GraphTypes.TotalHits: title = "Total Hits"; var allHits = CallGet <IList <HitResponse> >("statistics/AllHits"); itens = OrderHits(allHits); break; case GraphTypes.StatusOK: title = "Status 200"; var hitsOK = CallGet <IList <HitResponse> >("statistics/OKHits"); itens = OrderHits(hitsOK); break; case GraphTypes.TooManyRequests: title = "Status 429"; color = "#008000"; var hitsTooManyRequests = CallGet <IList <HitResponse> >("statistics/TooManyRequestsHits"); itens = OrderHits(hitsTooManyRequests); break; case GraphTypes.NotFound: title = "Status 404"; color = "#FF0000"; var hitsNotFound = CallGet <IList <HitResponse> >("statistics/NotFoundRequestsHits"); itens = OrderHits(hitsNotFound); break; case GraphTypes.Errors: title = "Status 500"; color = "#FF0000"; var hitsErrors = CallGet <IList <HitResponse> >("statistics/ErrorsRequestsHits"); itens = OrderHits(hitsErrors); break; case GraphTypes.AverageTime: title = "Average Time"; yAxesTitle = "milliseconds"; var hitsAverage = CallGet <IList <HitResponse> >("statistics/AllHits"); itens = CalculateAverageTime(hitsAverage); break; default: title = "Page Setup Error <br> Contact us -> [email protected] ;)"; break; } } catch (Exception ex) { title = "Ops... Error trying to load page <br>" + ex.Message; } return(Json( new { response = itens, title, yAxesTitle, color })); }
protected Graph(GraphTypes eventGraphType) => GraphType = eventGraphType;
public bool isBipartite_util <T>(List <List <T> > graph, int src, int nodes_size, int[] colorArr, GraphTypes graphType, int[] componentlist) { //Create a queue (FIFO) of vertex numbers and enqueue source vertex //for BFS traversal Queue <int> q = new Queue <int>(); //Create a color array to store colors assigned to all veritces. Vertex //number is used as index in this array. The value '-1' of colorArr[i] //is used to indicate that no color is assigned to vertex 'i'. The value //is used to indicate first color is assigned and value 0 indicates //second color is assigned. switch (graphType) { case (GraphTypes.Dense): { List <List <bool> > dense_graph = (List <List <bool> >)Convert.ChangeType(graph, typeof(List <List <bool> >)); //Assign first color to source if (colorArr[src] == -1) { colorArr[src] = 1; componentlist[src] = componentlistIndex; } q.Enqueue(src); //Run while there are vertices in queue (Similar to BFS) while (q.Count != 0) { //Dequeue a vertex from queue int u = q.Peek(); q.Dequeue(); //Find all non-colored adjacent vertices for (int v = 0; v < dense_graph[u].Count; ++v) { //An edge from u to v exists and destination v is not colored if (dense_graph[u][v] && (colorArr[v] == -1)) { //Assign alternate color to this adjacent v of u colorArr[v] = 1 - colorArr[u]; componentlist[v] = componentlistIndex; q.Enqueue(v); } //An edge from u to v exists and destination v is colored with //same color as u else if (dense_graph[u][v] && colorArr[v] == colorArr[u]) { return(false); } } } return(true); } case (GraphTypes.Sparse): { List <List <int> > sparse_graph = (List <List <int> >)Convert.ChangeType(graph, typeof(List <List <int> >)); //Assign first color to source if (colorArr[src] == -1) { colorArr[src] = 1; componentlist[src] = componentlistIndex; } q.Enqueue(src + 1); //Run while there are vertices in queue (Similar to BFS) while (q.Count != 0) { //Dequeue a vertex from queue int u = q.Peek(); q.Dequeue(); //int[] level = new int[graph.Count]; //int vertex = 0; for (int i = 1; i < sparse_graph[u - 1].Count; i++) { if ((colorArr[sparse_graph[u - 1][i] - 1] == -1)) { //Assign alternate color to this adjacent v of u colorArr[sparse_graph[u - 1][i] - 1] = 1 - colorArr[u - 1]; componentlist[sparse_graph[u - 1][i] - 1] = componentlistIndex; q.Enqueue(sparse_graph[u - 1][i]); } else if (colorArr[sparse_graph[u - 1][i] - 1] == colorArr[u - 1]) { return(false); } } } return(true); } default: return(false); } }
public static extern int result_get_solution(IntPtr ising, IsingTypes ising_type, GraphTypes graph_type, FloatTypes float_type, out IntPtr spins);
/// <summary> /// Create a new environment grapher. /// </summary> public EnvironmentGrapher(EnvironmentTracker tracker, GraphTypes graphType) { this.tracker = tracker; this.graphType = graphType; }