How can I plot a graph at the end of the function - graph

I need to implement a script where the user enters information for multiple samples. I need to draw a graph with that information, but I need to plot it with all information at the end of the execution. My actual script plots one graph every time the user enters information for one of the samples.
op=input('Digite a quantidade de compostos:');
i=1;
j=1;
k=1;
temp =0:5:100
while(i<=op)
produto=input('Digite o nome do produto:','s');
quant(i)=input('Digite a quantidade de amostras:')
lista{i}=produto;
for j =1:quant(i)
amostras(j,k)=input('Digite o valor da solubilidade:')
k++;
amostras(j,k)=input('Digite o valor da temperatura:')
k=1;
end
hold all;
gplot(amostras,amostras);
i++
end
hold off;

You can use the 'Visible' property of the figure to hide it during the execution of your loops and show it later.
So insert this before your while loop:
figure();
set(gcf, 'Visible', 'off');
and now at the end of your code, make it visible again with:
set(gcf, 'Visible', 'on');

[...] I need to plot it with all information at the end of the execution. My actual script plots one graph every time the user enters information for one of the samples.
Don't plot it each time. Store the values and plot everything at the end instead. Like so:
op = input ('Digite a quantidade de compostos: ');
lista = cell (op, 1);
amostras = cell (op, 1);
for i = 1:op
lista = input ('Digite o nome do produto: ','s');
quant = input ('Digite a quantidade de amostras: ');
amostras{i} = zeros (quant, 1);
for j = 1:quant
amostras{i}(j,1) = input ('Digite o valor da solubilidade: ');
amostras{i}(j,2) = input ('Digite o valor da temperatura: ');
endfor
endfor
## plot now

Related

Error when creating word document with ASP

i am new to asp. I have an error when the application try to create a word document.
This happens sometimes, in different machines and some users and I can't get to reproduce in testing environment (Only in production).
And at my workplace is very limited what I can try without asking to production area.
This is the error:
SCRIPT4605: este comando no está disponible para la lectura Este método o propiedad no está disponible porque.
Translation: This command is not available for reading. This method or property is not avaiable
I look for the error in production environment and it seems to be in these five lines, when trying to create a grid and insert a barcode(The creation of the barcode works fine).
Set myRange = objDoc.Range(0, 0)
Set myTable = objDoc.Tables.Add(myRange, 1, 1)
Set myCell = myTable.Cell(1, 1)
myCell.Range.ParagraphFormat.Alignment = 1
myCell.Range.InlineShapes.AddPicture "<%=archivo_temporal%>"
So, the objDoc is created fine, but its seems that does not have (It depends in the user and the machine) the Range() method.
Here is the entire function.
Sub OpenDoc(strLocation)
Dim iOut
Dim oElement
Dim objWord
Dim doc
Set objWord = CreateObject("Word.Application")
objWord.Visible = true
Set objDoc = objWord.Documents.Open(strLocation)
codigo_barras_b64 = DecodeString("<%=codigo_barras_b64%>")
set FSObj = Createobject("Scripting.FileSystemObject")
set file = FSObj.CreateTextFile("<%=archivo_temporal%>", true)
file.write (codigo_barras_b64)
set file = nothing
Set myRange = objDoc.Range(0, 0)
Set myTable = objDoc.Tables.Add(myRange, 1, 1)
Set myCell = myTable.Cell(1, 1)
myCell.Range.ParagraphFormat.Alignment = 1
myCell.Range.InlineShapes.AddPicture "<%=archivo_temporal%>"
iOut = objword.ActiveDocument.Variables.Add("Secretaria", "<%=sLimpiarTextArea(sValor(RSCarat, "secreDescrip"))%> ")'
iOut = objword.ActiveDocument.Variables.Add("Autos", "<%=sLimpiarTextArea(sValor(RSCarat, "expeAutos"))%> ")
iOut = objword.ActiveDocument.Variables.Add("Sobre", "<%=sLimpiarTextArea(sValor(RSCarat, "expeSobre"))%> ")
iOut = objword.ActiveDocument.Variables.Add("En", "<%=sLimpiarTextArea(sValor(RSCarat, "expeEn"))%> ")
iOut = objword.ActiveDocument.Variables.Add("Juez", "<%=sLimpiarTextArea(sValor(RSCarat, "juezNombres"))%> ")
iOut = objword.ActiveDocument.Variables.Add("ExpNro", "<%=sLimpiarTextArea(sValor(RSCarat, "expeNro"))%> ")
iOut = objword.ActiveDocument.Variables.Add("Fecha", "<%=sLimpiarTextArea(sValor(RSCarat, "fechaInicio"))%> ")
objWord.ActiveDocument.Fields.Update
objWord.ActiveDocument.SaveAs "c:\temp\tsj.doc"
objWord.Application.Activate
' Borra el archivo generado
Set MyFile = FSObj.GetFile("<%=archivo_temporal%>")
MyFile.Delete
set FSObj = nothing
Set objWord = Nothing
End Sub
Is anyway that I can insert the barcode in a different way to avoid these lines?
Someone have an idea why this error?
Some hints to look around?
Any help will be appreciated, Thanks!

How to weaken the connection component

I want to add a counter when traversing the graph,
for x in mycollection
for v,e,p in 1..1 any x._id graph'mygraph'
return v
I want to add a counter after traversing the collection,I want to go through the graph counter after traversal plus 1.
let count=1
for x in mycollection
for v,e,p in 1..1 any x._id graph'mygraph'
return v
count++
I am not interested in the length of the collection, I just want to traverse the graph after each, the counter is added 1
I wrote two unfinished js files,
In fact, I was trying to figure out the weak connected component in my graph,code show as below
'use strict';
function connectionGraph(vertex,count1,collection,graphName) {
var db = require('#arangodb').db;
var q2 = " for v,e,p in 1..1 any #vt._id graph #graph \n" +
" update x with{label:#count} in ##ttv \n" +
" filter v.label!=#count \n" +
" return MYFUNCTION::dfs(v,#count,##ttv)";
var param = {vt:vertex,count:count1,#ttv:collection,graph:graphName}
db._query(q2,param);
}
module.exports = connectionGraph;
'use strict';
function connection(c,collection,graphName) {
var db = require('#arangodb').db;
int c = 1;
var query = "for x in ##tv \n"
"for v,e,p in 1..1 any x._id graph #graph \n" +
" update x with{label:#count} in ##tv \n" +
" filter v.label!=#count \n" +
" return MYFUNCTION::dfs(v,#count,##collection,#graph)";
var param = {count:c,#tv:collection,graph:graphName};
db._query(query,param);
}
module.exports = connection;
I do not know how to write, can you help me?
I just wanted to find the weakly connected component of a graph.
An algorithm named "connected components" to find weakly connected components in a graph is available for ArangoDB.
It can be executed with:
var pregel = require("#arangodb/pregel");
pregel.start("connectedcomponents", "graphname")
The algorithm is documented at:
https://docs.arangodb.com/3.2/Manual/Graphs/Pregel/#connected-components

Reminds And Send me Email

I'm trying to develop a reminds app. This code is a framework that I need. I have 3 spreadsheets, and I intend, in each spreadsheets, monitor deadlines. When the deadline is less than five days, it should send an e-mail. It has worked well in the following manner:
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('2016.2');
var clientesInfo = sheet.getRange(2, 7, sheet.getLastRow() - 1, 2).getValues();
//Data de hoje na coluna G2;
for (var i = 0; i < clientesInfo.length; i++) {
if (clientesInfo[i][1] < 5 && clientesInfo[i][1] >= 0 ) {
MailApp.sendEmail("roger#tr.br", "Atenção! Prazo se esgotando(Isso é apenas um teste)", "Verifique tarefas que estão próximas de vencer, em: https://g.gl/plgTRU7");
} `enter code here`
}
}
But I want now that that same code, I can monitor multiple spreadsheets, spreadsheet 2016.2. How should I do? Create multiple ifs? What if I have 100 sheets? Will be 100 ifs?

Changing the last datarow from a asp:repeater table if data is shown in asp:label using vb.net using strings of dates

i have my dates changed to Journee if the 2 rows have the same date, but now i need to put together the dates that follow each other and have Journee. How can i do this, tried this code but it is not working, thanks in advance
Private Sub BindRepeaterData(ByVal noformationL As String)
Dim conSQL As New System.Data.SqlClient.SqlConnection
Dim cmdSQL As New System.Data.SqlClient.SqlCommand
conSQL.ConnectionString = Application("BACKstr")
conSQL.Open()
cmdSQL.Connection = conSQL
cmdSQL.CommandText = "select convert(char,[DateFormation],103) AS DateFormation,[DemiJournee] from [EXT$FORM_FormationDates] where NoFormation='" & Replace(noformationL, "'", "''") & "' and TypeDates = 0 order by DateFormation,DemiJourneeInt"
Dim ds As New System.Data.DataSet()
Dim da As New Data.SqlClient.SqlDataAdapter(cmdSQL)
da.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
'On fait un premier nouveau dataset avec table pour y mettre les données finales de DemiJournee
Dim dsfinal As New System.Data.DataSet()
dsfinal.Tables.Add("FinalData")
dsfinal.Tables("FinalData").Columns.Add("DateFormation")
dsfinal.Tables("FinalData").Columns.Add("DemiJournee")
'On suit le DS en comparant les rows et additionant a dsfinal et puis binding dsfinal to repeater
Dim totalrows = ds.Tables(0).Rows.Count
Dim rowpointer As Integer = 0
Dim r = 0
If totalrows > 2 Then
'Si nous avons plus de 2 rows
'On compare 1 row avec la suivante row jusqu'arrivé a les deux derniere rows
Do While r < totalrows - 2
If ds.Tables(0).Rows(r).Item("DateFormation") = ds.Tables(0).Rows(r + 1).Item("DateFormation") Then
'Les deux rows a comparé on la meme date
'Nous mettons seulemenent un row au lieu de deux dans la table
dsfinal.Tables("FinalData").Rows.Add(ds.Tables(0).Rows(r).Item("DateFormation"), "Journée")
r += 2 '+1 to r
rowpointer = r '+1 to rowpointer
Else
'Les 2 rows on differentes dates
'On met en premier le comparateur comme row.
'On laisse la suivante row pour la comparer avec la row apres elle.
dsfinal.Tables("FinalData").Rows.Add(ds.Tables(0).Rows(r).Item("DateFormation"), ds.Tables(0).Rows(r).Item("DemiJournee"))
r += 1
rowpointer = r
End If
Loop
End If
If rowpointer < totalrows - 1 Then
'On a besoin de comparer les deux restantes rows
If ds.Tables(0).Rows(rowpointer).Item("DateFormation") = ds.Tables(0).Rows(rowpointer + 1).Item("DateFormation") Then
'Les deux rows comparées on la meme date
'Nous mettons seulement 1 row dans la table
dsfinal.Tables("FinalData").Rows.Add(ds.Tables(0).Rows(rowpointer).Item("DateFormation"), "Journée")
Else
'Les 2 rows on dates différentes
'On mets les 2 rows dans la table
dsfinal.Tables("FinalData").Rows.Add(ds.Tables(0).Rows(rowpointer).Item("DateFormation"), ds.Tables(0).Rows(rowpointer).Item("DemiJournee"))
dsfinal.Tables("FinalData").Rows.Add(ds.Tables(0).Rows(rowpointer + 1).Item("DateFormation"), ds.Tables(0).Rows(rowpointer + 1).Item("DemiJournee"))
End If
Else
'Nous avons seulement un historique(record)
dsfinal.Tables("FinalData").Rows.Add(ds.Tables(0).Rows(rowpointer).Item("DateFormation"), ds.Tables(0).Rows(rowpointer).Item("DemiJournee"))
End If
ds = Nothing
If dsfinal.Tables(0).Rows.Count > 0 Then
'On fait un premier nouveau dataset avec table pour y mettre les données finales de DemiJournee
Dim dsfinal2 As New System.Data.DataSet()
dsfinal2.Tables.Add("FinalData")
dsfinal2.Tables("FinalData").Columns.Add("DateFormation")
dsfinal2.Tables("FinalData").Columns.Add("DemiJournee")
'On suit le DS en comparant les rows et additionant a dsfinal et puis binding dsfinal to repeater
Dim totalrows2 = dsfinal.Tables(0).Rows.Count
Dim rowpointer2 As Integer = 0
Dim r2 = 0
If totalrows2 > 2 Then
'Si nous avons plus de 2 rows
'On compare 1 row avec la suivante row jusqu'arrivé a les deux derniere rows
Do While r2 < totalrows2 - 2
If dsfinal.Tables(0).Rows(r2).Item("DemiJournee") = "Journée" Then
'Les deux rows a comparé on la meme date
'Nous mettons seulemenent un row au lieu de deux dans la table
dsfinal2.Tables("FinalData").Rows.Add(dsfinal.Tables(0).Rows(r2).Item("DateFormation") + " au " + dsfinal.Tables(0).Rows(r2 + 1).Item("DateFormation"), "Journée")
r2 += 1 '+1 to r
rowpointer2 = r2 '+1 to rowpointer
Else
'Les 2 rows on differentes dates
'On met en premier le comparateur comme row.
'On laisse la suivante row pour la comparer avec la row apres elle.
dsfinal2.Tables("FinalData").Rows.Add(dsfinal.Tables(0).Rows(r2).Item("DateFormation"), dsfinal.Tables(0).Rows(r2).Item("DemiJournee"))
dsfinal2.Tables("FinalData").Rows.Add(dsfinal.Tables(0).Rows(r2 + 1).Item("DateFormation"), dsfinal.Tables(0).Rows(r2 + 1).Item("DemiJournee"))
r2 += 2
rowpointer2 = r2
End If
Loop
End If
If rowpointer2 < totalrows2 - 1 Then
'On a besoin de comparer les deux restantes rows
If dsfinal.Tables(0).Rows(r2).Item("DemiJournee") = "Journée" Then
'Les deux rows comparées on la meme date
'Nous mettons seulement 1 row dans la table
dsfinal2.Tables("FinalData").Rows.Add(dsfinal.Tables(0).Rows(rowpointer2).Item("DateFormation"), "Journée")
Else
'Les 2 rows on dates différentes
'On mets les 2 rows dans la table
dsfinal2.Tables("FinalData").Rows.Add(dsfinal.Tables(0).Rows(rowpointer2).Item("DateFormation"), dsfinal.Tables(0).Rows(rowpointer2).Item("DemiJournee"))
dsfinal2.Tables("FinalData").Rows.Add(dsfinal.Tables(0).Rows(rowpointer2 + 1).Item("DateFormation"), dsfinal.Tables(0).Rows(rowpointer2 + 1).Item("DemiJournee"))
End If
Else
'Nous avons seulement un historique(record)
dsfinal2.Tables("FinalData").Rows.Add(dsfinal.Tables(0).Rows(rowpointer2).Item("DateFormation"), dsfinal.Tables(0).Rows(rowpointer2).Item("DemiJournee"))
End If
'clear le ds original
dsfinal = Nothing
rep_Dates.Visible = True
rep_Dates.DataSource = dsfinal2
rep_Dates.DataBind()
dsfinal2 = Nothing
Else
rep_Dates.Visible = False
End If
Else
rep_Dates.Visible = False
End If
conSQL.Close()
End Sub
OK Rafael... my solution...
I have created two repeaters so that I can see the first transformation and the second. You can just bind the last transformation to the repeater you have...
Any Questions... please ask.
Private Sub BindRepeaterData()
'For test I removed param
Dim conSQL As New System.Data.SqlClient.SqlConnection
Dim cmdSQL As New System.Data.SqlClient.SqlCommand
conSQL.ConnectionString = ConfigurationManager.ConnectionStrings("TestConn").ToString
'Change your connection string...
conSQL.Open()
cmdSQL.Connection = conSQL
cmdSQL.CommandText = "select convert(char,[DateFormation],103) AS DateFormation,[DemiJournee] from [TblTest] order by DateFormation"
'Change your Sql
Dim ds As New System.Data.DataSet()
Dim da As New Data.SqlClient.SqlDataAdapter(cmdSQL)
da.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
'Create a new dataset with table where we will store new data
Dim dsTemp As New DataSet()
dsTemp.Tables.Add("TempData")
dsTemp.Tables("TempData").Columns.Add("DateFormation")
dsTemp.Tables("TempData").Columns.Add("DemiJournee")
'Now we will go through ds comparing two rows at a time.
'If the two rows have the same date the only add one row to TempData changing the DemiJournee field to Journée.
'Else if not the same date then add one row but leave the second as we need to next compare it with its successor.
Dim totalrows = ds.Tables(0).Rows.Count
Dim rowpointer As Integer = 0
Dim r = 0
If totalrows > 2 Then
'We have more than two rows
'We compare one row against the next row until we get to the last two rows.
Do While r < totalrows - 2
If ds.Tables(0).Rows(r).Item("DateFormation") = ds.Tables(0).Rows(r + 1).Item("DateFormation") Then
'Both compared rows have same date
'We add just one row to table and change DemiJournee field to Journée
dsTemp.Tables("TempData").Rows.Add(ds.Tables(0).Rows(r).Item("DateFormation"), "Journée")
r += 2 'add 2 to r (we do not need to compare the second row as we have just condenced it)
rowpointer = r 'add 2 to rowpointer
Else
'The two rows have different dates
'add first comparitor as a row.
'we leave the second row to make comparision with the row after it
dsTemp.Tables("TempData").Rows.Add(ds.Tables(0).Rows(r).Item("DateFormation"), ds.Tables(0).Rows(r).Item("DemiJournee"))
r += 1
rowpointer = r
End If
Loop
End If
If rowpointer < totalrows - 1 Then
'We need to compare the remaining two rows
If ds.Tables(0).Rows(rowpointer).Item("DateFormation") = ds.Tables(0).Rows(rowpointer + 1).Item("DateFormation") Then
'Both compared rows have same date
'We add just one row to table
dsTemp.Tables("TempData").Rows.Add(ds.Tables(0).Rows(rowpointer).Item("DateFormation"), "Journée")
Else
'The two rows have different dates
'add both rows
dsTemp.Tables("TempData").Rows.Add(ds.Tables(0).Rows(rowpointer).Item("DateFormation"), ds.Tables(0).Rows(rowpointer).Item("DemiJournee"))
dsTemp.Tables("TempData").Rows.Add(ds.Tables(0).Rows(rowpointer + 1).Item("DateFormation"), ds.Tables(0).Rows(rowpointer + 1).Item("DemiJournee"))
End If
Else
'We only have one record
dsTemp.Tables("TempData").Rows.Add(ds.Tables(0).Rows(rowpointer).Item("DateFormation"), ds.Tables(0).Rows(rowpointer).Item("DemiJournee"))
End If
'dsTemp now contains the corrected data.
rep_Dates.Visible = True
rep_Dates.DataSource = dsTemp
rep_Dates.DataBind()
'clear original ds so that we can sort our data again
ds.Tables(0).Clear()
'The second sort needs to go through TempData comparing two rows but this time compare the DemiJournee field
'If the two rows have Journée as their DemiJournee value AND the dates are sequential then store then as
'10/01/2014 - 11/01/2014 Journée... continue comparing with the next row. If that is Journée and a sequential date
'then we would need to store as 10/01/2014 - 12/01/2014 Journée and so on.
'If not sequential or not Journée then store as original.
Dim sd As String = "" 'used to store the start date of our sequence
Dim cd As String = "" 'used to store the compare date of our sequence
Dim ed As String = "" 'used to store the end date or our sequence
totalrows = dsTemp.Tables("TempData").Rows.Count
rowpointer = 0
r = 0
If totalrows > 2 Then
'We have more than two rows
'We compare one row against the next row until we get to the last two rows.
Do While r < totalrows - 2
If dsTemp.Tables("TempData").Rows(r).Item("DemiJournee") = "Journée" And dsTemp.Tables("TempData").Rows(r + 1).Item("DemiJournee") = "Journée" Then
'Both compared rows have DemiJournee = "Journée"
If sd = "" Then
'We have no startdate so start a new sequence
sd = dsTemp.Tables("TempData").Rows(r).Item("DateFormation")
cd = dsTemp.Tables("TempData").Rows(r).Item("DateFormation")
ed = dsTemp.Tables("TempData").Rows(r + 1).Item("DateFormation")
If CDate(ed) = DateAdd(DateInterval.Day, 1, CDate(cd)) Then
'The two date are sequential...
'We don't add any rows until we run out of compared rows or sequential dates
r += 1
rowpointer = r
Else
'The two dates are not sequential. We add the first row and leave the second to compare with the next row in line
ds.Tables(0).Rows.Add(dsTemp.Tables("TempData").Rows(r).Item("DateFormation"), dsTemp.Tables("TempData").Rows(r).Item("DemiJournee"))
r += 1
rowpointer = r
sd = ""
cd = ""
ed = ""
End If
Else
'we already have a start date
cd = dsTemp.Tables("TempData").Rows(r).Item("DemiJournee")
ed = dsTemp.Tables("TempData").Rows(r + 1).Item("DemiJournee")
If CDate(ed) = DateAdd(DateInterval.Day, 1, CDate(cd)) Then
'The two date are sequential...
'We don't add any rows until we run out of compared rows or sequential dates
r += 1
rowpointer = r
Else
'The two dates are not sequential.
'Our sequence has broken so we finish this sequence by adding a new row
'sd - ed Journée
ds.Tables(0).Rows.Add(sd.ToString & " - " & ed.ToString, "Journée")
r += 1
rowpointer = r
sd = ""
cd = ""
ed = ""
End If
End If
Else
'The two rows have different DemiJournee
If sd = "" Then
'We have no squence so
'add first comparitor as a row.
'we leave the second row to make comparision with the row after it
ds.Tables(0).Rows.Add(dsTemp.Tables("TempData").Rows(r).Item("DateFormation"), dsTemp.Tables("TempData").Rows(r).Item("DemiJournee"))
r += 1
rowpointer = r
Else
'we have a sequence and our sequence has broken so we finish this sequence by adding a new row
ds.Tables(0).Rows.Add(sd.ToString & " - " & ed.ToString, "Journée")
r += 1
rowpointer = r
sd = ""
cd = ""
ed = ""
End If
End If
Loop
End If
'Now finish off with remaining rows
If rowpointer < totalrows - 1 Then
'We need to compare the remaining two rows
If dsTemp.Tables("TempData").Rows(rowpointer).Item("DemiJournee") = "Journée" And dsTemp.Tables("TempData").Rows(rowpointer + 1).Item("DemiJournee") = "Journée" Then
'Both compared rows have DemiJournee = "Journée"
If sd = "" Then
'We have no startdate so start a new sequence
sd = dsTemp.Tables("TempData").Rows(rowpointer).Item("DateFormation")
cd = dsTemp.Tables("TempData").Rows(rowpointer).Item("DateFormation")
ed = dsTemp.Tables("TempData").Rows(rowpointer + 1).Item("DateFormation")
If CDate(ed) = DateAdd(DateInterval.Day, 1, CDate(cd)) Then
'The two date are sequential...
'These are the last two rows so we ad one condenced row
ds.Tables(0).Rows.Add(sd.ToString & " - " & ed.ToString, "Journée")
Else
'The two dates are not sequential. We add two new rows
ds.Tables(0).Rows.Add(dsTemp.Tables("TempData").Rows(rowpointer).Item("DateFormation"), dsTemp.Tables("TempData").Rows(rowpointer).Item("DemiJournee"))
ds.Tables(0).Rows.Add(dsTemp.Tables("TempData").Rows(rowpointer + 1).Item("DateFormation"), dsTemp.Tables("TempData").Rows(rowpointer + 1).Item("DemiJournee"))
End If
Else
'we already have a start date
cd = dsTemp.Tables("TempData").Rows(r).Item("DemiJournee")
ed = dsTemp.Tables("TempData").Rows(r + 1).Item("DemiJournee")
If CDate(ed) = DateAdd(DateInterval.Day, 1, CDate(cd)) Then
'The two date are sequential...
'These are the last two rows so we ad one condenced row
ds.Tables(0).Rows.Add(sd.ToString & " - " & ed.ToString, "Journée")
Else
'The two dates are not sequential.
'Our sequence has broken so we finish this sequence by adding a new row
'sd - ed Journée
ds.Tables(0).Rows.Add(sd.ToString & " - " & cd.ToString, "Journée")
'plus the last row
ds.Tables(0).Rows.Add(dsTemp.Tables("TempData").Rows(rowpointer + 1).Item("DateFormation"), dsTemp.Tables("TempData").Rows(rowpointer + 1).Item("DemiJournee"))
End If
End If
ds.Tables(0).Rows.Add(dsTemp.Tables("TempData").Rows(rowpointer).Item("DateFormation"), "Journée")
Else
'The two rows have different dates
'add both rows
ds.Tables(0).Rows.Add(dsTemp.Tables("TempData").Rows(rowpointer).Item("DateFormation"), dsTemp.Tables("TempData").Rows(rowpointer).Item("DemiJournee"))
ds.Tables(0).Rows.Add(dsTemp.Tables("TempData").Rows(rowpointer + 1).Item("DateFormation"), dsTemp.Tables("TempData").Rows(rowpointer + 1).Item("DemiJournee"))
End If
Else
'We only have one record
ds.Tables(0).Rows.Add(dsTemp.Tables("TempData").Rows(rowpointer).Item("DateFormation"), dsTemp.Tables("TempData").Rows(rowpointer).Item("DemiJournee"))
End If
rep_DemiJournee.Visible = True
rep_DemiJournee.DataSource = ds
rep_DemiJournee.DataBind()
dsTemp = Nothing
ds = Nothing
Else
rep_Dates.Visible = False
rep_DemiJournee.Visible = False
End If
conSQL.Close()
End Sub
Result with data you supplied gives...
rep_Dates
Dates
15/01/2014 Journée
16/01/2014 Journée
17/01/2014 Matin
20/01/2014 Après-midi
27/01/2014 Après-midi
28/01/2014 Matin
29/01/2014 Matin
rep_DemiJouree
Dates
15/01/2014 - 16/01/2014 Journée
17/01/2014 Matin
20/01/2014 Après-midi
27/01/2014 Après-midi
28/01/2014 Matin
29/01/2014 Matin

Representing RDF data in JUNG graph

I'm loading RDF data into a JUNG graph to do some analysis.
So I create a new graph with:
DirectedGraph g = new DirectedSparseGraph<String,GraphLink>();
I created a support class for specifying the link:
public class GraphLink {
String uri;
Float weight;
}
Then I populate it like this:
for each rdf triple <s,p,o>{
g.addVertex( s )
g.addVertex( o )
GraphLink link = new GraphLink()
link.uri = pred
link.weight = some weight;
g.addEdge( link, s, o )
}
Is this an efficient way of doing it or there are better ways?
The representation of the edges is very counterintuitive, but if I do:
g.addEdge( p, s, o )
I get an exception of duplicated edge.
Any hints?
UPDATE: this code seems to work well:
DirectedGraph<RDFNode,Statement> g = new DirectedSparseGraph<RDFNode,Statement>()
// list all statements
// TODO: pagination for very large graphs.
assert m.size() < 10000000,"graph is too large."
m.listStatements().each{ stm->
RDFNode sub = stm.getSubject()
RDFNode obj = stm.getObject()
g.addVertex( sub )
if ( includeLiterals || !obj.isLiteral() ){
g.addVertex( obj )
g.addEdge( stm, sub, obj, EdgeType.DIRECTED )
}
}
Mulone
This may not be what you want at all, but you could try JenaJung, which presents a jena model as a Jung graph.
From the README file:
Model model = FileManager.get().loadModel("http://example.com/data.rdf");
Graph<RDFNode, Statement> g = new JenaJungGraph(model);
Layout<RDFNode, Statement> layout = new FRLayout(g);
layout.setSize(new Dimension(300, 300));
BasicVisualizationServer<RDFNode, Statement> viz =
new BasicVisualizationServer<RDFNode, Statement>(layout);

Resources